mirror of https://github.com/docker/docker-py.git
Change format in which hosts are being stored for Swarm services
Signed-off-by: Michael Hankin <mhank@users.noreply.github.com>
This commit is contained in:
parent
8d770b012d
commit
0134939c2c
|
@ -137,7 +137,7 @@ class ContainerSpec(dict):
|
|||
if labels is not None:
|
||||
self['Labels'] = labels
|
||||
if hosts is not None:
|
||||
self['Hosts'] = format_extra_hosts(hosts)
|
||||
self['Hosts'] = format_extra_hosts(hosts, task=True)
|
||||
|
||||
if mounts is not None:
|
||||
parsed_mounts = []
|
||||
|
|
|
@ -564,9 +564,15 @@ def format_environment(environment):
|
|||
return [format_env(*var) for var in six.iteritems(environment)]
|
||||
|
||||
|
||||
def format_extra_hosts(extra_hosts):
|
||||
def format_extra_hosts(extra_hosts, task=False):
|
||||
# Use format dictated by Swarm API if container is part of a task
|
||||
if task:
|
||||
return [
|
||||
'{} {}'.format(v, k) for k, v in sorted(six.iteritems(extra_hosts))
|
||||
]
|
||||
|
||||
return [
|
||||
'{} {}'.format(v, k) for k, v in sorted(six.iteritems(extra_hosts))
|
||||
'{}:{}'.format(k, v) for k, v in sorted(six.iteritems(extra_hosts))
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ class ContainerCollectionTest(unittest.TestCase):
|
|||
'Dns': ['8.8.8.8'],
|
||||
'DnsOptions': ['foo'],
|
||||
'DnsSearch': ['example.com'],
|
||||
'ExtraHosts': ['1.2.3.4 foo'],
|
||||
'ExtraHosts': ['foo:1.2.3.4'],
|
||||
'GroupAdd': ['blah'],
|
||||
'IpcMode': 'foo',
|
||||
'KernelMemory': 123,
|
||||
|
|
Loading…
Reference in New Issue