diff --git a/changelogs/fragments/1187-docker.yml b/changelogs/fragments/1187-docker.yml new file mode 100644 index 00000000..83794875 --- /dev/null +++ b/changelogs/fragments/1187-docker.yml @@ -0,0 +1,2 @@ +bugfixes: + - "Docker CLI based modules - work around bug in Docker 29.0.0 that caused a breaking change in ``docker version --format json`` output (https://github.com/ansible-collections/community.docker/issues/1185, https://github.com/ansible-collections/community.docker/pull/1187)." diff --git a/plugins/module_utils/_common_cli.py b/plugins/module_utils/_common_cli.py index 36484880..74e1a28f 100644 --- a/plugins/module_utils/_common_cli.py +++ b/plugins/module_utils/_common_cli.py @@ -126,13 +126,16 @@ class AnsibleDockerClientBase: self._info: dict[str, t.Any] | None = None if needs_api_version: + api_version_string = self._version["Server"].get( + "ApiVersion" + ) or self._version["Server"].get("APIVersion") if not isinstance(self._version.get("Server"), dict) or not isinstance( - self._version["Server"].get("ApiVersion"), str + api_version_string, str ): self.fail( "Cannot determine Docker Daemon information. Are you maybe using podman instead of docker?" ) - self.docker_api_version_str = to_text(self._version["Server"]["ApiVersion"]) + self.docker_api_version_str = to_text(api_version_string) self.docker_api_version = LooseVersion(self.docker_api_version_str) min_docker_api_version = min_docker_api_version or "1.25" if self.docker_api_version < LooseVersion(min_docker_api_version):