Compare container images to Config.Image.

pull/18777/head
Ash Wilson 10 years ago committed by Matt Clay
parent 17334b21ea
commit 93b620ea8a

@ -424,6 +424,13 @@ def get_split_image_tag(image):
return resource, tag
def normalize_image(image):
"""
Normalize a Docker image name to include the implied :latest tag.
"""
return ":".join(get_split_image_tag(image))
def is_running(container):
'''Return True if an inspected container is in a state we consider "running."'''
@ -1113,11 +1120,13 @@ class DockerManager(object):
if inspected:
repo_tags = self.get_image_repo_tags()
else:
image, tag = get_split_image_tag(self.module.params.get('image'))
repo_tags = [':'.join([image, tag])]
repo_tags = [normalize_image(self.module.params.get('image'))]
for i in self.client.containers(all=True):
running_image = i['Image']
details = self.client.inspect_container(i['Id'])
details = _docker_id_quirk(details)
running_image = normalize_image(details['Config']['Image'])
running_command = i['Command'].strip()
if name:
@ -1132,9 +1141,6 @@ class DockerManager(object):
matches = image_matches and command_matches
if matches:
details = self.client.inspect_container(i['Id'])
details = _docker_id_quirk(details)
deployed.append(details)
return deployed

Loading…
Cancel
Save