mirror of https://github.com/docker/docker-py.git
Default to /tcp for port definitions in create_container()
Fixes #141. Signed-off-by: Maxime Petazzoni <max@signalfuse.com>
This commit is contained in:
parent
77edd8b601
commit
dad95ba679
|
|
@ -134,15 +134,12 @@ class Client(requests.Session):
|
||||||
exposed_ports = {}
|
exposed_ports = {}
|
||||||
for port_definition in ports:
|
for port_definition in ports:
|
||||||
port = port_definition
|
port = port_definition
|
||||||
proto = None
|
proto = 'tcp'
|
||||||
if isinstance(port_definition, tuple):
|
if isinstance(port_definition, tuple):
|
||||||
if len(port_definition) == 2:
|
if len(port_definition) == 2:
|
||||||
proto = port_definition[1]
|
proto = port_definition[1]
|
||||||
port = port_definition[0]
|
port = port_definition[0]
|
||||||
exposed_ports['{0}{1}'.format(
|
exposed_ports['{0}/{1}'.format(port, proto)] = {}
|
||||||
port,
|
|
||||||
'/' + proto if proto else ''
|
|
||||||
)] = {}
|
|
||||||
ports = exposed_ports
|
ports = exposed_ports
|
||||||
|
|
||||||
if volumes and isinstance(volumes, list):
|
if volumes and isinstance(volumes, list):
|
||||||
|
|
|
||||||
|
|
@ -223,9 +223,9 @@ class DockerClientTest(unittest.TestCase):
|
||||||
{"Tty": false, "Image": "busybox",
|
{"Tty": false, "Image": "busybox",
|
||||||
"Cmd": ["ls"], "AttachStdin": false,
|
"Cmd": ["ls"], "AttachStdin": false,
|
||||||
"Memory": 0, "ExposedPorts": {
|
"Memory": 0, "ExposedPorts": {
|
||||||
"1111": {},
|
"1111/tcp": {},
|
||||||
"2222/udp": {},
|
"2222/udp": {},
|
||||||
"3333": {}
|
"3333/tcp": {}
|
||||||
},
|
},
|
||||||
"AttachStderr": true,
|
"AttachStderr": true,
|
||||||
"AttachStdout": true, "OpenStdin": false,
|
"AttachStdout": true, "OpenStdin": false,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue