Skip to content

Commit d069792

Browse files
author
Adrian Slade
committedNov 14, 2014
Allow extra_hosts to be specified in service
1 parent 65ae22e commit d069792

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed
 

‎fig/service.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
log = logging.getLogger(__name__)
1616

1717

18-
DOCKER_CONFIG_KEYS = ['image', 'command', 'hostname', 'domainname', 'user', 'detach', 'stdin_open', 'tty', 'mem_limit', 'ports', 'environment', 'dns', 'volumes', 'entrypoint', 'privileged', 'volumes_from', 'net', 'working_dir']
18+
DOCKER_CONFIG_KEYS = ['image', 'command', 'hostname', 'domainname', 'user', 'detach', 'stdin_open', 'tty', 'mem_limit', 'ports', 'environment', 'dns', 'volumes', 'entrypoint', 'privileged', 'volumes_from', 'net', 'working_dir', 'extra_hosts']
1919
DOCKER_CONFIG_HINTS = {
2020
'link' : 'links',
2121
'port' : 'ports',
@@ -261,6 +261,7 @@ def start_container(self, container=None, intermediate_container=None, **overrid
261261
privileged = options.get('privileged', False)
262262
net = options.get('net', 'bridge')
263263
dns = options.get('dns', None)
264+
extra_hosts = options.get('extra_hosts', None)
264265

265266
container.start(
266267
links=self._get_links(link_to_self=options.get('one_off', False)),
@@ -270,6 +271,7 @@ def start_container(self, container=None, intermediate_container=None, **overrid
270271
privileged=privileged,
271272
network_mode=net,
272273
dns=dns,
274+
extra_hosts=extra_hosts
273275
)
274276
return container
275277

@@ -370,6 +372,11 @@ def _get_container_create_options(self, override_options, one_off=False):
370372
container_options['environment'] = dict(split_env(e) for e in container_options['environment'])
371373
container_options['environment'] = dict(resolve_env(k, v) for k, v in container_options['environment'].iteritems())
372374

375+
if 'extra_hosts' in container_options:
376+
if isinstance(container_options['extra_hosts'], list):
377+
container_options['extra_hosts'] = dict(split_env(e) for e in container_options['extra_hosts'])
378+
container_options['extra_hosts'] = dict(resolve_env(k, v) for k, v in container_options['extra_hosts'].iteritems())
379+
373380
if self.can_be_built():
374381
if len(self.client.images(name=self._build_tag_name())) == 0:
375382
self.build()

0 commit comments

Comments
 (0)