containers / podman

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

Podman cannot be used by docker-compose when docker binary is installed #16938

Closed TomaszGasior closed 1 year ago

TomaszGasior commented 1 year ago

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description

The problem is similar to https://github.com/containers/podman/issues/12206 but error message is different so I decided to create new issue for that.

I have user-wide podman service enabled (systemctl enable --now --user podman.socket) and I have DOCKER_HOST=unix://$XDG_RUNTIME_DIR/podman/podman.sock in my environment. I have both dockerd, docker binary and podman installed in my OS (Fedora 37 in clean VM). docker-compose invokes docker binary and that binary cannot communicate with podman-provided API.

I want to have podman working with docker-compose without need to uninstall docker from my OS.

Steps to reproduce the issue:

Environment:

export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/podman/podman.sock  # in .bashrc, .profile, etc.
sudo dnf install /usr/bin/docker # moby-engine rpm
sudo dnf install podman 
sudo dnf  install docker-compose

When I want to just work on my project:

git clone https://github.com/TomaszGasior/RadioLista-v3.git
cd RadioLista-v3
docker-compose up  # I verified DOCKER_HOST is set

Describe the results you received:

[tomasz@fedora RadioLista-v3]$ docker-compose up
Building http
Sending build context to Docker daemon  4.608kB
request returned Bad Request for API route and version http://%2Frun%2Fuser%2F1000%2Fpodman%2Fpodman.sock/v1.41/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&shmsize=0&t=radiolista-v3_http&target=&ulimits=null&version=1, check if the server supports the requested API version
ERROR: Service 'http' failed to build : Build failed

(Error occurs when images are not built yet only.)

I have to remove docker from my OS and install docker binary from podman-docker to make it working:

sudo dnf remove moby-engine
sudo dnf install podman-docker

Then docker-compose up works.

Describe the results you expected:

I don't have to install fake docker binary pointing to podman to make podman working with docker-compose. I don't have to use wrapping script like in the previous issue https://github.com/containers/podman/issues/12206.

Additional information you deem important (e.g. issue happens only occasionally):

Output of podman version:

Client:       Podman Engine
Version:      4.3.1
API Version:  4.3.1
Go Version:   go1.19.2
Built:        Fri Nov 11 16:01:27 2022
OS/Arch:      linux/amd64

Output of podman info:

host:
  arch: amd64
  buildahVersion: 1.28.0
  cgroupControllers:
  - cpu
  - io
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.5-1.fc37.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.5, commit: '
  cpuUtilization:
    idlePercent: 96.44
    systemPercent: 1.21
    userPercent: 2.35
  cpus: 4
  distribution:
    distribution: fedora
    variant: workstation
    version: "37"
  eventLogger: journald
  hostname: fedora
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
  kernel: 6.0.14-300.fc37.x86_64
  linkmode: dynamic
  logDriver: journald
  memFree: 212766720
  memTotal: 2064703488
  networkBackend: netavark
  ociRuntime:
    name: crun
    package: crun-1.7.2-2.fc37.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.7.2
      commit: 0356bf4aff9a133d655dc13b1d9ac9424706cac4
      rundir: /run/user/1000/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +YAJL
  os: linux
  remoteSocket:
    exists: true
    path: /run/user/1000/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: true
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.2.0-8.fc37.x86_64
    version: |-
      slirp4netns version 1.2.0
      commit: 656041d45cfca7a4176f6b7eed9e4fe6c11e8383
      libslirp: 4.7.0
      SLIRP_CONFIG_VERSION_MAX: 4
      libseccomp: 2.5.3
  swapFree: 1321201664
  swapTotal: 2064642048
  uptime: 0h 22m 37.00s
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  volume:
  - local
registries:
  search:
  - registry.fedoraproject.org
  - registry.access.redhat.com
  - docker.io
  - quay.io
store:
  configFile: /home/tomasz/.config/containers/storage.conf
  containerStore:
    number: 0
    paused: 0
    running: 0
    stopped: 0
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/tomasz/.local/share/containers/storage
  graphRootAllocated: 23957864448
  graphRootUsed: 4367663104
  graphStatus:
    Backing Filesystem: btrfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 0
  runRoot: /run/user/1000/containers
  volumePath: /home/tomasz/.local/share/containers/storage/volumes
version:
  APIVersion: 4.3.1
  Built: 1668178887
  BuiltTime: Fri Nov 11 16:01:27 2022
  GitCommit: ""
  GoVersion: go1.19.2
  Os: linux
  OsArch: linux/amd64
  Version: 4.3.1

Package info (e.g. output of rpm -q podman or apt list podman or brew info podman):

podman-4.3.1-1.fc37.x86_64

also

[tomasz@fedora RadioLista-v3]$ docker-compose --version
docker-compose version 1.29.2, build unknown
[tomasz@fedora RadioLista-v3]$ rpm -q docker-compose
docker-compose-1.29.2-6.fc37.noarch
[tomasz@fedora RadioLista-v3]$ 

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide?

Yes

Additional environment details (AWS, VirtualBox, physical, etc.):

Fedora 37 clean VM

baude commented 1 year ago

which docker-compose is this?

TomaszGasior commented 1 year ago

which docker-compose is this?

Sorry but I don't understand. Could you please explain? :)

baude commented 1 year ago

Are you using the python docker-compose or the go-based docker compose.

TomaszGasior commented 1 year ago

It's already specified in issue description: I provided RPM package version. That's Python-based implementation with - in the name.

baude commented 1 year ago

can you strace the docker-compose command? i think i remember that docker compose python actually also calls the docker binary for a couple of things?

TomaszGasior commented 1 year ago

Using simple technique with overriding docker binary by script which logs all arguments I found that docker-compose actually does something simple:

docker build --tag SOME_NAME --iidfile SOME_TMP_FILE PATH_TO_DIRECTORY_CONTAINING_DOCKERFILE

The thing is docker build with DOCKER_HOST set to Podman just does not work, completely. Just bare docker build DIRECTORY does not work causing the following error while podman build DIRECTORY works properly.

request returned Bad Request for API route and version http://%2Frun%2Fuser%2F1000%2Fpodman%2Fpodman.sock/v1.41/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&shmsize=0&target=&ulimits=null&version=1, check if the server supports the requested API version

For example you can try podman build container/http/ vs docker build container/http/ with CWD in linked repository.

docker-compose up running through strace: strace.txt

docker binary version:

[tomasz@fedora RadioLista-v3]$ docker --version
Docker version 20.10.21, build baeda1f
[tomasz@fedora RadioLista-v3]$ rpm -q moby-engine
moby-engine-20.10.21-1.fc37.x86_64
Luap99 commented 1 year ago

I am pretty sure this was fixed in https://github.com/containers/podman/pull/16380, this should be fixed in podman v4.4, the cachefrom param is causing this. Duplicate of #15928