Skip to content

Commit

Permalink
Don't assume ExposedPorts exists (bug ansible#2257)
Browse files Browse the repository at this point in the history
A recent change [1] in docker between v1.8.2 and v1.8.3 changed what
is returned in the json when inspecting an image. Five variables which
could have been expected before will now be omited when empty. Only
one of those variables is being addressed in the docker, ExposedPorts.

Unfortunately there was also no API version change on this so this
can't be easily corrected with pinning the API to the older version.

This does a get() which will return None if the variable is not in the
dict formed from the json that was returned. Everything else works the
same way.

[1] moby/moby@9098628
  • Loading branch information
SamYaple authored and Chris Dail committed Nov 5, 2015
1 parent 3a1293e commit 2105bdd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cloud/docker/docker.py
Expand Up @@ -928,7 +928,7 @@ def get_differing_containers(self):
continue

# EXPOSED PORTS
expected_exposed_ports = set((image['ContainerConfig']['ExposedPorts'] or {}).keys())
expected_exposed_ports = set((image['ContainerConfig'].get('ExposedPorts') or {}).keys())
for p in (self.exposed_ports or []):
expected_exposed_ports.add("/".join(p))

Expand Down

0 comments on commit 2105bdd

Please sign in to comment.