Skip to content

Client.port() only reports the UDP exposed port mapping if the same port is configured to be mapped on UDP and TCP. #792

@devmapal

Description

@devmapal

E.g.:
docker ps

CONTAINER ID  IMAGE         COMMAND        CREATED        STATUS        PORTS                                         NAMES
6348dd5bc7c2  ubuntu:14.04  /usr/bin/bash  8 seconds ago  Up 8 seconds  0.0.0.0:49153->80/udp, 0.0.0.0:49159->80/tcp  expose_ports

In ipython

In [1]: docker_client.port('6348dd5bc7c2', 80)
Out[1]: [{u'HostIp': u'0.0.0.0', u'HostPort': u'49153'}]

The reason seems to lie in /docker/api/container.py, line 208-210

def port(self, container, private_port):

...

h_ports = port_settings.get(s_port + '/udp')
if h_ports is None:
    h_ports = port_settings.get(s_port + '/tcp')

Instead of basically only accepting a port number for private_port and trying for udp and tcp exposed ports, I'd suggest that the method rather accepts an explicit private_port input like 1234/tcp.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions