diff options
author | Joffrey F <joffrey@docker.com> | 2015-09-28 12:06:10 -0700 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2015-09-28 12:06:10 -0700 |
commit | d0ccc2e261c2abb3d87dd664011ac83015938534 (patch) | |
tree | 207710ba118940cfb4ed259988e2a1ece361e1da /docker/api | |
parent | 5e331a55a8e8e10354693172dce1aa63f58ebe97 (diff) | |
download | docker-py-792-fix-ports-command.tar.gz |
Support explicit protocol in Client.port792-fix-ports-command
User can now specify a protocol in Client.port using the port/proto
syntax. Default port is now TCP instead of UDP (to match the
behavior of `docker port`) when no proto is specified.
Regression test
Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'docker/api')
-rw-r--r-- | docker/api/container.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/docker/api/container.py b/docker/api/container.py index e7ddd73..f2d8a5b 100644 --- a/docker/api/container.py +++ b/docker/api/container.py @@ -196,7 +196,7 @@ class ContainerApiMixin(object): res = self._get(self._url("/containers/{0}/json", container)) self._raise_for_status(res) json_ = res.json() - s_port = str(private_port) + private_port = str(private_port) h_ports = None # Port settings is None when the container is running with @@ -205,9 +205,12 @@ class ContainerApiMixin(object): if port_settings is None: return None - h_ports = port_settings.get(s_port + '/udp') + if '/' in private_port: + return port_settings.get(private_port) + + h_ports = port_settings.get(private_port + '/tcp') if h_ports is None: - h_ports = port_settings.get(s_port + '/tcp') + h_ports = port_settings.get(private_port + '/udp') return h_ports |