Skip to content

Commit

Permalink
Fixed value for missing host port for newer docker desktop versions
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Avrahami <avrahami.ben@gmail.com>
  • Loading branch information
bentheiii committed Jul 26, 2021
1 parent a9748a8 commit 9f3f97c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docker/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def _convert_port_binding(binding):
result['HostPort'] = binding

if result['HostPort'] is None:
result['HostPort'] = ''
result['HostPort'] = '0'
else:
result['HostPort'] = str(result['HostPort'])

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/api_container_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ def test_create_container_with_port_binds(self):
assert '4444/tcp' in port_bindings
assert '5555/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 [
{"HostPort": "2222", "HostIp": ""}
] == port_bindings['2222/tcp']
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/models_containers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def test_create_container_args(self):
'PidsLimit': 500,
'PortBindings': {
'1111/tcp': [{'HostIp': '', 'HostPort': '4567'}],
'2222/tcp': [{'HostIp': '', 'HostPort': ''}]
'2222/tcp': [{'HostIp': '', 'HostPort': '0'}]
},
'Privileged': True,
'PublishAllPorts': True,
Expand Down

0 comments on commit 9f3f97c

Please sign in to comment.