Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

podman service: inconsistent exit code when called from docker #18889

Closed
oleastre opened this issue Jun 14, 2023 · 9 comments · Fixed by #18912
Closed

podman service: inconsistent exit code when called from docker #18889

oleastre opened this issue Jun 14, 2023 · 9 comments · Fixed by #18912
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@oleastre
Copy link

oleastre commented Jun 14, 2023

Issue Description

I use some shared scripts between docker and podman environments. To allow some compatibility, I run podman as a service and configure docker to use the podman socket.
I noticed some strange behaviour in one script where we check for the exit code of a run command.
In some cases, I correctly get the command exit code, in other cases, I simply get 0.

Some informations:

  • Podman version: 4.5.0
  • fedora package: podman-4.5.0-1.fc37.x86_64
  • docker package: moby-engine-20.10.23-1.fc37.x86_64

Steps to reproduce the issue

Steps to reproduce the issue

  1. start podman as a service systemctl start --user podman.socket
  2. set environment variable: export DOCKER_HOST="unix://$(podman info -f "{{.Host.RemoteSocket.Path}}")"
  3. Run some containers that exit in error and compare exit code of the command:
$ podman run busybox /bin/sh -c 'exit 3' ; echo $?
3
$ podman run --rm busybox /bin/sh -c 'exit 3' ; echo $?
3
$ docker run busybox /bin/sh -c 'exit 3' ; echo $?
3
$ docker run --rm busybox /bin/sh -c 'exit 3' ; echo $?
0

Describe the results you received

I would expect all commands to return 3, but when ran through docker with the --rm flag I get 0

Describe the results you expected

All variants to return the same exit code.

podman info output

host:
  arch: amd64
  buildahVersion: 1.30.0
  cgroupControllers:
  - cpu
  - io
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.7-2.fc37.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.7, commit: '
  cpuUtilization:
    idlePercent: 94.88
    systemPercent: 1.58
    userPercent: 3.54
  cpus: 16
  databaseBackend: boltdb
  distribution:
    distribution: fedora
    variant: workstation
    version: "37"
  eventLogger: journald
  hostname: patator
  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.3.4-101.fc37.x86_64
  linkmode: dynamic
  logDriver: journald
  memFree: 2931601408
  memTotal: 37629321216
  networkBackend: netavark
  ociRuntime:
    name: crun
    package: crun-1.8.5-1.fc37.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.8.5
      commit: b6f80f766c9a89eb7b1440c0a70ab287434b17ed
      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: 8588619776
  swapTotal: 8589930496
  uptime: 23h 3m 49.00s (Approximately 0.96 days)
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - registry.fedoraproject.org
  - registry.access.redhat.com
  - docker.io
  - quay.io
store:
  configFile: /home/olivier/.config/containers/storage.conf
  containerStore:
    number: 5
    paused: 0
    running: 0
    stopped: 5
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/olivier/.local/share/containers/storage
  graphRootAllocated: 510389125120
  graphRootUsed: 341180133376
  graphStatus:
    Backing Filesystem: btrfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 124
  runRoot: /run/user/1000/containers
  transientStore: false
  volumePath: /home/olivier/.local/share/containers/storage/volumes
version:
  APIVersion: 4.5.0
  Built: 1681486976
  BuiltTime: Fri Apr 14 17:42:56 2023
  GitCommit: ""
  GoVersion: go1.19.7
  Os: linux
  OsArch: linux/amd64
  Version: 4.5.0

Podman in a container

No

Privileged Or Rootless

Rootless

Upstream Latest Release

No

Additional environment details

Additional environment details

Additional information

No response

@oleastre oleastre added the kind/bug Categorizes issue or PR as related to a bug. label Jun 14, 2023
@vrothberg
Copy link
Member

Thanks for reaching out! To me it looks like a Docker bug. run --rm busybox /bin/sh -c 'exit 3' ; echo $? should exit 3 not 0 as Docker does.

@oleastre
Copy link
Author

If I run the same command against a docker engine/socket, it works as expected.
So, the problem is when the socket is provided by the podman service.
That's why I suspect it to be a bug in podman service, not in docker.
Is there anything I could try to find on which side of the socket the problem is ?

@Luap99
Copy link
Member

Luap99 commented Jun 14, 2023

I am 99% sure that this was report before but I cannot find that issue right now (if it even exists).

@Luap99
Copy link
Member

Luap99 commented Jun 14, 2023

#16056 but it was closed without proper resolution so I am good with keeping this one open here.

@vrothberg
Copy link
Member

Thanks for clarifying, @oleastre. I agree, it looks an issue on the podman side.

@rhatdan
Copy link
Member

rhatdan commented Jun 14, 2023

I would figure this is a race between the container being removed and the exit code being checked? I still see this as a docker daemon bug, since the client is exiting with the wrong exit code. Unless docker intends to ignore any containers exit code, if the container is a --rm?

@vrothberg
Copy link
Member

Let's dig a bit deeper. The docker client works fine with the docker daemon but it consistently returns 0 running against podman.

@vrothberg
Copy link
Member

With --rm, Docker sends wait?condition=removed` which Podman doesn't process correctly. I'll wrap up a fix.

vrothberg added a commit to vrothberg/libpod that referenced this issue Jun 16, 2023
The "removed" condition mapped to an undefined state which ultimately
rendered the wait endpoint to return an incorrect exit code.  Instead,
map "removed" to "exited" to make sure Podman returns the expected
exit code.

Fixes: containers#18889
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
@vrothberg
Copy link
Member

Opened #18912

vrothberg added a commit to vrothberg/libpod that referenced this issue Jun 16, 2023
The "removed" condition mapped to an undefined state which ultimately
rendered the wait endpoint to return an incorrect exit code.  Instead,
map "removed" to "exited" to make sure Podman returns the expected
exit code.

Fixes: containers#18889
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
cgiradkar pushed a commit to cgiradkar/podman that referenced this issue Jul 12, 2023
The "removed" condition mapped to an undefined state which ultimately
rendered the wait endpoint to return an incorrect exit code.  Instead,
map "removed" to "exited" to make sure Podman returns the expected
exit code.

Fixes: containers#18889
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
cgiradkar pushed a commit to cgiradkar/podman that referenced this issue Jul 13, 2023
The "removed" condition mapped to an undefined state which ultimately
rendered the wait endpoint to return an incorrect exit code.  Instead,
map "removed" to "exited" to make sure Podman returns the expected
exit code.

Fixes: containers#18889
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
cgiradkar pushed a commit to cgiradkar/podman that referenced this issue Jul 17, 2023
The "removed" condition mapped to an undefined state which ultimately
rendered the wait endpoint to return an incorrect exit code.  Instead,
map "removed" to "exited" to make sure Podman returns the expected
exit code.

Fixes: containers#18889
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
cgiradkar pushed a commit to cgiradkar/podman that referenced this issue Jul 17, 2023
The "removed" condition mapped to an undefined state which ultimately
rendered the wait endpoint to return an incorrect exit code.  Instead,
map "removed" to "exited" to make sure Podman returns the expected
exit code.

Fixes: containers#18889
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 15, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants