Fixed value for missing host port for newer docker desktop versions

Signed-off-by: Ben Avrahami <avrahami.ben@gmail.com>
This commit is contained in:
ben avrahami 2021-07-26 14:05:13 +03:00 committed by Ben Avrahami
parent a9748a8b70
commit 9f3f97ce94
3 changed files with 3 additions and 3 deletions

View File

@ -88,7 +88,7 @@ def _convert_port_binding(binding):
result['HostPort'] = binding result['HostPort'] = binding
if result['HostPort'] is None: if result['HostPort'] is None:
result['HostPort'] = '' result['HostPort'] = '0'
else: else:
result['HostPort'] = str(result['HostPort']) result['HostPort'] = str(result['HostPort'])

View File

@ -577,7 +577,7 @@ class CreateContainerTest(BaseAPIClientTest):
assert '4444/tcp' in port_bindings assert '4444/tcp' in port_bindings
assert '5555/tcp' in port_bindings assert '5555/tcp' in port_bindings
assert '6666/tcp' in port_bindings assert '6666/tcp' in port_bindings
assert [{"HostPort": "", "HostIp": ""}] == port_bindings['1111/tcp'] assert [{"HostPort": "0", "HostIp": ""}] == port_bindings['1111/tcp']
assert [ assert [
{"HostPort": "2222", "HostIp": ""} {"HostPort": "2222", "HostIp": ""}
] == port_bindings['2222/tcp'] ] == port_bindings['2222/tcp']

View File

@ -163,7 +163,7 @@ class ContainerCollectionTest(unittest.TestCase):
'PidsLimit': 500, 'PidsLimit': 500,
'PortBindings': { 'PortBindings': {
'1111/tcp': [{'HostIp': '', 'HostPort': '4567'}], '1111/tcp': [{'HostIp': '', 'HostPort': '4567'}],
'2222/tcp': [{'HostIp': '', 'HostPort': ''}] '2222/tcp': [{'HostIp': '', 'HostPort': '0'}]
}, },
'Privileged': True, 'Privileged': True,
'PublishAllPorts': True, 'PublishAllPorts': True,