Moved network_mode default to create_host_config ; small fix to preserve blank host_config in start if no option is provided

This commit is contained in:
Joffrey F 2015-07-29 12:45:15 -07:00
parent daea185a23
commit e32726e83d
2 changed files with 3 additions and 11 deletions

View File

@ -780,7 +780,7 @@ class Client(clientbase.ClientBase):
publish_all_ports=publish_all_ports, links=links, dns=dns,
privileged=privileged, dns_search=dns_search, cap_add=cap_add,
cap_drop=cap_drop, volumes_from=volumes_from, devices=devices,
network_mode=network_mode, restart_policy=restart_policy,
network_mode=network_mode or '', restart_policy=restart_policy,
extra_hosts=extra_hosts, read_only=read_only, pid_mode=pid_mode,
ipc_mode=ipc_mode, security_opt=security_opt, ulimits=ulimits
)

View File

@ -428,6 +428,8 @@ def create_host_config(
if network_mode:
host_config['NetworkMode'] = network_mode
elif network_mode is None:
host_config['NetworkMode'] = 'default'
if restart_policy:
host_config['RestartPolicy'] = restart_policy
@ -615,16 +617,6 @@ def create_container_config(
if volumes_from is not None:
raise errors.InvalidVersion(message.format('volumes_from'))
# NetworkMode must be present and valid in host config from 1.20 onwards
if compare_version('1.20', version) >= 0:
if host_config is None:
host_config = {'NetworkMode': 'default'}
else:
if 'NetworkMode' not in host_config:
host_config['NetworkMode'] = 'default'
elif host_config['NetworkMode'] == '':
host_config['NetworkMode'] = 'default'
return {
'Hostname': hostname,
'Domainname': domainname,