Skip to content

Commit 29c67c3

Browse files
committed
Added support for extra_hosts in create_host_config
1 parent f2ad888 commit 29c67c3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

docker/utils/utils.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ def create_host_config(
300300
binds=None, port_bindings=None, lxc_conf=None,
301301
publish_all_ports=False, links=None, privileged=False,
302302
dns=None, dns_search=None, volumes_from=None, network_mode=None,
303-
restart_policy=None, cap_add=None, cap_drop=None, devices=None
303+
restart_policy=None, cap_add=None, cap_drop=None, devices=None,
304+
extra_hosts=None
304305
):
305306
host_config = {
306307
'Privileged': privileged,
@@ -341,6 +342,15 @@ def create_host_config(
341342
port_bindings
342343
)
343344

345+
if extra_hosts:
346+
if isinstance(extra_hosts, dict):
347+
extra_hosts = [
348+
'{0}:{1}'.format(k, v)
349+
for k, v in sorted(six.iteritems(extra_hosts))
350+
]
351+
352+
host_config['ExtraHosts'] = extra_hosts
353+
344354
host_config['PublishAllPorts'] = publish_all_ports
345355

346356
if links:

0 commit comments

Comments
 (0)