15
15
log = logging .getLogger (__name__ )
16
16
17
17
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' ]
19
19
DOCKER_CONFIG_HINTS = {
20
20
'link' : 'links' ,
21
21
'port' : 'ports' ,
@@ -261,6 +261,7 @@ def start_container(self, container=None, intermediate_container=None, **overrid
261
261
privileged = options .get ('privileged' , False )
262
262
net = options .get ('net' , 'bridge' )
263
263
dns = options .get ('dns' , None )
264
+ extra_hosts = options .get ('extra_hosts' , None )
264
265
265
266
container .start (
266
267
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
270
271
privileged = privileged ,
271
272
network_mode = net ,
272
273
dns = dns ,
274
+ extra_hosts = extra_hosts
273
275
)
274
276
return container
275
277
@@ -370,6 +372,11 @@ def _get_container_create_options(self, override_options, one_off=False):
370
372
container_options ['environment' ] = dict (split_env (e ) for e in container_options ['environment' ])
371
373
container_options ['environment' ] = dict (resolve_env (k , v ) for k , v in container_options ['environment' ].iteritems ())
372
374
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
+
373
380
if self .can_be_built ():
374
381
if len (self .client .images (name = self ._build_tag_name ())) == 0 :
375
382
self .build ()
0 commit comments