mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-27 21:01:27 -07:00
Fix computation of port bindings. Port bindings configuration can be a list if several host ports are bound to the same guest port.
This commit is contained in:
parent
c1d7678cc2
commit
f11c451bfa
1 changed files with 6 additions and 7 deletions
|
@ -1071,15 +1071,14 @@ class DockerManager(object):
|
||||||
for container_port, config in self.port_bindings.iteritems():
|
for container_port, config in self.port_bindings.iteritems():
|
||||||
if isinstance(container_port, int):
|
if isinstance(container_port, int):
|
||||||
container_port = "{0}/tcp".format(container_port)
|
container_port = "{0}/tcp".format(container_port)
|
||||||
bind = {}
|
|
||||||
if len(config) == 1:
|
if len(config) == 1:
|
||||||
bind['HostIp'] = "0.0.0.0"
|
expected_bound_ports[container_port] = [{'HostIp': "0.0.0.0", 'HostPort': ""}]
|
||||||
bind['HostPort'] = ""
|
elif isinstance(config[0], tuple):
|
||||||
|
expected_bound_ports[container_port] = []
|
||||||
|
for hostip, hostport in config:
|
||||||
|
expected_bound_ports[container_port].append({ 'HostIp': hostip, 'HostPort': str(hostport)})
|
||||||
else:
|
else:
|
||||||
bind['HostIp'] = config[0]
|
expected_bound_ports[container_port] = [{'HostIp': config[0], 'HostPort': str(config[1])}]
|
||||||
bind['HostPort'] = str(config[1])
|
|
||||||
|
|
||||||
expected_bound_ports[container_port] = [bind]
|
|
||||||
|
|
||||||
actual_bound_ports = container['HostConfig']['PortBindings'] or {}
|
actual_bound_ports = container['HostConfig']['PortBindings'] or {}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue