containers / podman

Podman: A tool for managing OCI containers and pods.
https://podman.io
Apache License 2.0
23.15k stars 2.36k forks source link

Compatibility with Docker CLI #23344

Open ch0fe opened 2 months ago

ch0fe commented 2 months ago

Feature request description

Currently, podman version and podman info do not list some of the version information that would be available on docker version and docker info. It would be nice if this could be addressed, making podman (esp. podman compose) compatible with tools that rely on this, concretely the docker-compose ansible module (https://github.com/ansible-collections/community.docker/issues/891).

Suggest potential solution

The output should be compatible to what tools expect from docker commands.

Have you considered any alternatives?

Not using podman when relying on these integrations.

Additional context

No response

Luap99 commented 2 months ago

please provide exact examples of what is needed. How does the docker output look like compared to podman and what keys does the ansible role care about?

ch0fe commented 2 months ago

docker version includes info on the client and server version:

    "Client": {
        "CloudIntegration": "v1.0.35+desktop.4",
        "Version": "24.0.6",
        "ApiVersion": "1.43",
        "DefaultAPIVersion": "1.43",
        "GitCommit": "ed223bc",
        "GoVersion": "go1.20.7",
        "Os": "windows",
        "Arch": "amd64",
        "BuildTime": "Mon Sep  4 12:32:48 2023",
        "Context": "default"
    },
    "Server": {
        "Platform": {
            "Name": "Docker Desktop 4.23.0 (120376)"
        },
        "Components": [
            {
                "Name": "Engine",
                "Version": "24.0.6",
                "Details": {
                    "ApiVersion": "1.43",
                    "Arch": "amd64",
                    "BuildTime": "Mon Sep  4 12:32:16 2023",
                    "Experimental": "false",
                    "GitCommit": "1a79695",
                    "GoVersion": "go1.20.7",
                    "KernelVersion": "5.10.102.1-microsoft-standard-WSL2",
                    "MinAPIVersion": "1.12",
                    "Os": "linux"
                }
            },
            {
                "Name": "containerd",
                "Version": "1.6.22",
                "Details": {
                    "GitCommit": "8165feabfdfe38c65b599c4993d227328c231fca"
                }
            },
            {
                "Name": "runc",
                "Version": "1.1.8",
                "Details": {
                    "GitCommit": "v1.1.8-0-g82f18fe"
                }
            },
            {
                "Name": "docker-init",
                "Version": "0.19.0",
                "Details": {
                    "GitCommit": "de40ad0"
                }
            }
        ],
        "Version": "24.0.6",
        "ApiVersion": "1.43",
        "MinAPIVersion": "1.12",
        "GitCommit": "1a79695",
        "GoVersion": "go1.20.7",
        "Os": "linux",
        "Arch": "amd64",
        "KernelVersion": "5.10.102.1-microsoft-standard-WSL2",
        "BuildTime": "2023-09-04T12:32:16.000000000+00:00"
    }
}

podman version only includes info on the client:

{
    "Client": {
        "APIVersion": "4.9.4-rhel",
        "Version": "4.9.4-rhel",
        "GoVersion": "go1.21.11 (Red Hat 1.21.11-1.el9_4)",
        "GitCommit": "",
        "BuiltTime": "Tue Jul  9 06:01:17 2024",
        "Built": 1720519277,
        "OsArch": "linux/amd64",
        "Os": "linux"
    }
}

docker info includes info on the compose plugin in ClientInfo.Plugins:

{
        "SchemaVersion": "0.1.0",
        "Vendor": "Docker Inc.",
        "Version": "v2.21.0-desktop.1",
        "ShortDescription": "Docker Compose",
        "Name": "compose",
        "Path": "C:\\Program Files\\Docker\\cli-plugins\\docker-compose.exe"
      }

podman info does not.

The Ansible module in question wants to read Server.ApiVersion from docker version and expects a compose plugin in ClientInfo.Plugins from docker info

afbjorklund commented 2 months ago

You need to use podman --remote version

And probably need docker version for ApiVersion?

But docker-compose is a standalone binary, it is not a plug-in (with Podman)

$ docker-compose version
Docker Compose version v2.28.1
$ docker-buildx version
github.com/docker/buildx v0.16.0 10c9ff901c1c255b58969dd2ade4789acbbab3bb
afbjorklund commented 2 months ago

Podman client will say: (i.e. libpod socket)

"APIVersion": "5.1.2", "Version": "5.1.2",

Docker client will say: (i.e. compat socket)

"Version": "5.1.2", "ApiVersion": "1.41", "MinAPIVersion": "1.24",

Most likely a Docker client would expect the Docker API version, and not the Podman API version.

So you can't really use podman-docker to emulate the docker client, but need to use a real client...

i.e. install docker and docker-compose

not podman-docker and podman-compose

Luap99 commented 2 months ago

Yes using the docker client against the podman server might be better in this case.

If the tool is trying to use the libpod API version it will not result in something useful and depending on how they handle it cause it to error out anyway.

afbjorklund commented 2 months ago

Currently they just return errors, rather than trying to support docker-compose or podman APIVersion:

        if not isinstance(cli_info.get('ClientInfo'), dict):
            self.fail('Cannot determine Docker client information. Are you maybe using podman instead of docker?')
        for plugin in cli_info['ClientInfo'].get('Plugins') or []:
            if not isinstance(self._version.get('Server'), dict) or not isinstance(self._version['Server'].get('ApiVersion'), string_types):
                self.fail('Cannot determine Docker Daemon information. Are you maybe using podman instead of docker?')
            self.docker_api_version_str = to_native(self._version['Server']['ApiVersion'])

The error message would be bettter as "Are you maybe using podman client instead of docker client?"

github-actions[bot] commented 1 month ago

A friendly reminder that this issue had no activity for 30 days.

flxmr commented 1 month ago

because this had some activity and my problem is related: I have a symlink docker -> podman. Now if I run docker --version on my shell, I get podman version .... However, if I run docker --version within a script, I get docker version .... But it's still podman running. What is going on there?

afbjorklund commented 1 month ago

You probably installed the "podman-docker" package, instead of the "docker-ce-cli" (or "moby-engine") package.

Note: The real client will say "Docker version".

$ podman --version
podman version 4.9.3
$ docker --version
Docker version 27.1.1, build 6312585

The first word is just $0 (name of symlink)

flxmr commented 1 month ago

So capital d?! - very weird, now tried on Fedora and here it behaves consistently at least - however it has a different minor version (4.9.3 -> 4.9.4). But yes, I checked with bash -c "docker info" (and which) and I'm calling the podman-executable with the symlink. Weird.