containers / podman

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

When using podman as a backend for docker cli `docker ps` fails to show port-forwarding correctly #22367

Closed VinGarcia closed 6 months ago

VinGarcia commented 7 months ago

Issue Description

I have podman and podman desktop installed on my ARM MacOS.

I am still using the docker CLI tool although the backend is podman-desktop, and I got confused today when docker ps reported an incorrect value for a specific container's ports. When I use podman ps though it shows the ports correctly, and if I try to connect the the host port it works fine, so it is just a visualization problem.

Steps to reproduce the issue

I prepared a small reproducible example:

$ docker run --name podman-bug-report --rm -p 9080:80 -d ubuntu bash -c 'sleep 20'
$ docker ps | grep podman-bug-report
b5ec6d9ee0b5   ubuntu:latest                                            "bash -c sleep 20"       5 seconds ago    Up 5 seconds    80/tcp                     podman-bug-report
$ podman ps | grep podman-bug-report
b5ec6d9ee0b5  docker.io/library/ubuntu:latest                         bash -c sleep 20      7 seconds ago   Up 7 seconds             0.0.0.0:9080->80/tcp                        podman-bug-report

If you look at the "ports" section of both outputs you will see that the podman CLI is correctly displaying 0.0.0.0:9080->80/tcp, but docker is only displaying 80/tcp, which I think is not the intended behavior.

I did notice one interesting thing though, if I include a source IP on the port pattern, e.g. ::1:9080:80 instead of just 9080:80 the docker CLI does show the correct value, e.g.:

$ docker run --name podman-bug-report --rm -p ::1:9080:80 -d ubuntu bash -c 'sleep 20'
7f031353825a6babe4de4f1aa312e2ff781e22f1e0094b77efd10a37103b47b8
$ docker ps | grep podman-bug-report 
7f031353825a   ubuntu:latest                                            "bash -c sleep 20"       10 seconds ago   Up 9 seconds    ::1:9080->80/tcp           podman-bug-report
$ podman ps | grep podman-bug-report 
7f031353825a  docker.io/library/ubuntu:latest                         bash -c sleep 20      14 seconds ago  Up 14 seconds            ::1:9080->80/tcp                            podman-bug-report

Describe the results you received

docker cli shows an incorrect value for the port field

Describe the results you expected

I expected the output of docker ps to match the output of podman ps when displaying which host ports are forwarded to each container.

podman info output

host:
  arch: arm64
  buildahVersion: 1.33.5
  cgroupControllers:
  - cpuset
  - cpu
  - io
  - memory
  - pids
  - rdma
  - misc
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.10-1.fc39.aarch64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.10, commit: '
  cpuUtilization:
    idlePercent: 99.4
    systemPercent: 0.27
    userPercent: 0.33
  cpus: 5
  databaseBackend: sqlite
  distribution:
    distribution: fedora
    variant: coreos
    version: "39"
  eventLogger: journald
  freeLocks: 1990
  hostname: localhost.localdomain
  idMappings:
    gidmap: null
    uidmap: null
  kernel: 6.7.5-200.fc39.aarch64
  linkmode: dynamic
  logDriver: journald
  memFree: 184709120
  memTotal: 2044342272
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.10.0-1.fc39.aarch64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 1.10.0
    package: netavark-1.10.3-1.fc39.aarch64
    path: /usr/libexec/podman/netavark
    version: netavark 1.10.3
  ociRuntime:
    name: crun
    package: crun-1.14.3-1.fc39.aarch64
    path: /usr/bin/crun
    version: |-
      crun version 1.14.3
      commit: 1961d211ba98f532ea52d2e80f4c20359f241a98
      rundir: /run/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +YAJL
  os: linux
  pasta:
    executable: /usr/bin/pasta
    package: passt-0^20240220.g1e6f92b-1.fc39.aarch64
    version: |
      pasta 0^20240220.g1e6f92b-1.fc39.aarch64-pasta
      Copyright Red Hat
      GNU General Public License, version 2 or later
        <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.
  remoteSocket:
    exists: true
    path: /run/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: false
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: true
  serviceIsRemote: true
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.2.2-1.fc39.aarch64
    version: |-
      slirp4netns version 1.2.2
      commit: 0ee2d87523e906518d34a6b423271e4826f71faf
      libslirp: 4.7.0
      SLIRP_CONFIG_VERSION_MAX: 4
      libseccomp: 2.5.3
  swapFree: 0
  swapTotal: 0
  uptime: 790h 19m 40.00s (Approximately 32.92 days)
  variant: v8
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - docker.io
store:
  configFile: /usr/share/containers/storage.conf
  containerStore:
    number: 38
    paused: 0
    running: 12
    stopped: 26
  graphDriverName: overlay
  graphOptions:
    overlay.imagestore: /usr/lib/containers/storage
    overlay.mountopt: nodev,metacopy=on
  graphRoot: /var/lib/containers/storage
  graphRootAllocated: 106769133568
  graphRootUsed: 20517179392
  graphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Supports shifting: "true"
    Supports volatile: "true"
    Using metacopy: "true"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 78
  runRoot: /run/containers/storage
  transientStore: false
  volumePath: /var/lib/containers/storage/volumes
version:
  APIVersion: 4.9.3
  Built: 1708357248
  BuiltTime: Mon Feb 19 12:40:48 2024
  GitCommit: ""
  GoVersion: go1.21.7
  Os: linux
  OsArch: linux/arm64
  Version: 4.9.3

Podman in a container

No

Privileged Or Rootless

Privileged

Upstream Latest Release

No

Additional environment details

Its an MacBook Pro M1 running Sonoma 14.3.1 (23D60)

Additional information

No response

Luap99 commented 6 months ago

Please test this with podman 5.0 again, I assume this works there.