From 9cd46a7d41c3fc717395735e99891132f2099710 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Fri, 11 Feb 2022 12:23:36 +0100 Subject: [PATCH] Try to make more compatible with podman-docker. (#292) --- .../fragments/292-docker-podman-compatibility.yml | 2 ++ plugins/module_utils/common.py | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/292-docker-podman-compatibility.yml diff --git a/changelogs/fragments/292-docker-podman-compatibility.yml b/changelogs/fragments/292-docker-podman-compatibility.yml new file mode 100644 index 00000000..94b0bf88 --- /dev/null +++ b/changelogs/fragments/292-docker-podman-compatibility.yml @@ -0,0 +1,2 @@ +bugfixes: + - "docker_container, docker_image - adjust image finding code to pecularities of ``podman-docker``'s API emulation when Docker short names like ``redis`` are used (https://github.com/ansible-collections/community.docker/issues/292)." diff --git a/plugins/module_utils/common.py b/plugins/module_utils/common.py index c8da5877..f4295066 100644 --- a/plugins/module_utils/common.py +++ b/plugins/module_utils/common.py @@ -525,11 +525,18 @@ class AnsibleDockerClientBase(Client): self.log("Check for docker.io image: %s" % lookup) images = self._image_lookup(lookup, tag) if not images: - # Last case: if docker.io wasn't there, it can be that - # the image wasn't found either (#15586) + # Last case for some Docker versions: if docker.io wasn't there, + # it can be that the image wasn't found either + # (https://github.com/ansible/ansible/pull/15586) lookup = "%s/%s" % (registry, repo_name) self.log("Check for docker.io image: %s" % lookup) images = self._image_lookup(lookup, tag) + if not images and '/' not in repo_name: + # This seems to be happening with podman-docker + # (https://github.com/ansible-collections/community.docker/issues/291) + lookup = "%s/library/%s" % (registry, repo_name) + self.log("Check for docker.io image: %s" % lookup) + images = self._image_lookup(lookup, tag) if len(images) > 1: self.fail("Registry returned more than one result for %s:%s" % (name, tag))