Compare container images to Config.Image.

reviewable/pr18780/r1
Ash Wilson 10 years ago
parent d8ab661d0a
commit 47f4c3f2e5

@ -420,6 +420,13 @@ def get_split_image_tag(image):
return resource, tag 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): def is_running(container):
'''Return True if an inspected container is in a state we consider "running."''' '''Return True if an inspected container is in a state we consider "running."'''
@ -1109,11 +1116,13 @@ class DockerManager(object):
if inspected: if inspected:
repo_tags = self.get_image_repo_tags() repo_tags = self.get_image_repo_tags()
else: else:
image, tag = get_split_image_tag(self.module.params.get('image')) repo_tags = [normalize_image(self.module.params.get('image'))]
repo_tags = [':'.join([image, tag])]
for i in self.client.containers(all=True): 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() running_command = i['Command'].strip()
if name: if name:
@ -1128,9 +1137,6 @@ class DockerManager(object):
matches = image_matches and command_matches matches = image_matches and command_matches
if matches: if matches:
details = self.client.inspect_container(i['Id'])
details = _docker_id_quirk(details)
deployed.append(details) deployed.append(details)
return deployed return deployed

Loading…
Cancel
Save