From 558f2ace1f3448dd50c17d38de9a50f5850c050a Mon Sep 17 00:00:00 2001 From: Ed Hein Date: Fri, 12 Jun 2015 12:36:52 +0200 Subject: [PATCH] Fix computation of port bindings. Port bindings configuration can be a list if several host ports are bound to the same guest port. --- cloud/docker/docker.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cloud/docker/docker.py b/cloud/docker/docker.py index cb6d3dae075..b04b6ee335a 100644 --- a/cloud/docker/docker.py +++ b/cloud/docker/docker.py @@ -1041,15 +1041,14 @@ class DockerManager(object): for container_port, config in self.port_bindings.iteritems(): if isinstance(container_port, int): container_port = "{0}/tcp".format(container_port) - bind = {} if len(config) == 1: - bind['HostIp'] = "0.0.0.0" - bind['HostPort'] = "" + expected_bound_ports[container_port] = [{'HostIp': "0.0.0.0", '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: - bind['HostIp'] = config[0] - bind['HostPort'] = str(config[1]) - - expected_bound_ports[container_port] = [bind] + expected_bound_ports[container_port] = [{'HostIp': config[0], 'HostPort': str(config[1])}] actual_bound_ports = container['HostConfig']['PortBindings'] or {}