Default to /tcp for port definitions in create_container()

Fixes #141.

Signed-off-by: Maxime Petazzoni <max@signalfuse.com>
This commit is contained in:
Maxime Petazzoni 2014-01-16 09:09:16 -08:00
parent 77edd8b601
commit dad95ba679
2 changed files with 4 additions and 7 deletions

View File

@ -134,15 +134,12 @@ class Client(requests.Session):
exposed_ports = {}
for port_definition in ports:
port = port_definition
proto = None
proto = 'tcp'
if isinstance(port_definition, tuple):
if len(port_definition) == 2:
proto = port_definition[1]
port = port_definition[0]
exposed_ports['{0}{1}'.format(
port,
'/' + proto if proto else ''
)] = {}
exposed_ports['{0}/{1}'.format(port, proto)] = {}
ports = exposed_ports
if volumes and isinstance(volumes, list):

View File

@ -223,9 +223,9 @@ class DockerClientTest(unittest.TestCase):
{"Tty": false, "Image": "busybox",
"Cmd": ["ls"], "AttachStdin": false,
"Memory": 0, "ExposedPorts": {
"1111": {},
"1111/tcp": {},
"2222/udp": {},
"3333": {}
"3333/tcp": {}
},
"AttachStderr": true,
"AttachStdout": true, "OpenStdin": false,