mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-02 00:33:09 +00:00
Compare container images to Config.Image.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user