Skip to content

Commit

Permalink
Merge pull request #4 from chassing/master
Browse files Browse the repository at this point in the history
fix NoneType is not interable in case of no port mapping
  • Loading branch information
ShaneDrury committed Aug 12, 2016
2 parents 64653ac + e187f86 commit fbefe33
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions dockerintegration/docker.py
Expand Up @@ -82,13 +82,16 @@ def internal_port_from_docker(docker_port):


def port_mappings_from_container(docker_container):
return {
internal_port_from_docker(internal): [
HostAddress(
ip=address['HostIp'],
port=int(address['HostPort'])
)
for address in addresses
mappings = {}
for internal, addresses in six.iteritems(docker_container.ports):
if not addresses:
mappings[internal_port_from_docker(internal)] = []
else:
mappings[internal_port_from_docker(internal)] = [
HostAddress(
ip=address['HostIp'],
port=int(address['HostPort'])
)
for address in addresses
]
for internal, addresses in six.iteritems(docker_container.ports)
}
return mappings

0 comments on commit fbefe33

Please sign in to comment.