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

Container does not get automatically removed as specified by the --rm flag after failing due to a --publish port already in use #15049

Closed
eriksjolund opened this issue Jul 24, 2022 · 1 comment · Fixed by #15060
Assignees
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

@eriksjolund
Copy link
Contributor

eriksjolund commented Jul 24, 2022

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

/kind bug

Description

Container does not get automatically removed as specified by the --rm flag after failing due to a --publish port already in use. It works differently with Docker. After running the same command with Docker the container does not exist afterwards.

(I'm not quite sure, maybe this is less of a bug and more of a feature request?)

Steps to reproduce the issue:

$ podman run -p 1200:80 --rm --name testing1 -d   docker.io/library/nginx
7772ea10f1f2c925073ddac648f2f68e8bdfc73aca81bd13f14a5fcb9a8b5c51
$ podman run -p 1200:80 --rm --name testing2 -d   docker.io/library/nginx
Error: rootlessport listen tcp 0.0.0.0:1200: bind: address already in use
$ podman container list -a | grep testing
7772ea10f1f2  docker.io/library/nginx:latest   nginx -g daemon o...  30 seconds ago  Up 31 seconds ago          0.0.0.0:1200->80/tcp  testing1
846ce730ed18  docker.io/library/nginx:latest   nginx -g daemon o...  18 seconds ago  Created                    0.0.0.0:1200->80/tcp  testing2
$ 

Describe the results you received:

The container testing2 exists (as shown by the command podman container list -a)

Describe the results you expected:

The container testing2 shouldn't exist.

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

I did a test with Docker on macOS Monterey 12.5:

erik@N ~ % docker run -p 1200:80 --rm --name testing1 -d docker.io/library/nginx
856e65132b72c309fa2ddb31cf89eca8fc9d5d5f5a1317c6ba081625ffc5884f
erik@N ~ % docker run -p 1200:80 --rm --name testing2 -d docker.io/library/nginx
134b4f838b3fc31b114821aaed1257ac632cc123886cc5e2147ad475e9153778
docker: Error response from daemon: driver failed programming external connectivity on endpoint testing2 (624907e086df28f32f5809fbd183e2f1444a0bc4c1259e29744d8e436bbf374b): Bind for 0.0.0.0:1200 failed: port is already allocated.
erik@N ~ % docker container list -a | grep testing
856e65132b72   nginx     "/docker-entrypoint.…"   20 seconds ago       Up 19 seconds       0.0.0.0:1200->80/tcp   testing1
erik@N ~ % 

Output of podman version:

Client:       Podman Engine
Version:      4.1.1
API Version:  4.1.1
Go Version:   go1.18.3
Built:        Wed Jun 22 18:17:44 2022
OS/Arch:      linux/amd64

Output of podman info --debug:

Client:       Podman Engine
Version:      4.1.1
API Version:  4.1.1
Go Version:   go1.18.3
Built:        Wed Jun 22 18:17:44 2022
OS/Arch:      linux/amd64
[test179@asus user]$ podman info --debug
host:
  arch: amd64
  buildahVersion: 1.26.1
  cgroupControllers:
  - cpu
  - io
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.0-2.fc36.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.0, commit: '
  cpuUtilization:
    idlePercent: 99.91
    systemPercent: 0.03
    userPercent: 0.05
  cpus: 16
  distribution:
    distribution: fedora
    variant: workstation
    version: "36"
  eventLogger: journald
  hostname: asus
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1090
      size: 1
    - container_id: 1
      host_id: 5756448
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1090
      size: 1
    - container_id: 1
      host_id: 5756448
      size: 65536
  kernel: 5.18.13-200.fc36.x86_64
  linkmode: dynamic
  logDriver: journald
  memFree: 134475776
  memTotal: 7578865664
  networkBackend: netavark
  ociRuntime:
    name: crun
    package: crun-1.5-1.fc36.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.5
      commit: 54ebb8ca8bf7e6ddae2eb919f5b82d1d96863dea
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
  os: linux
  remoteSocket:
    path: /run/user/1090/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-0.2.beta.0.fc36.x86_64
    version: |-
      slirp4netns version 1.2.0-beta.0
      commit: 477db14a24ff1a3de3a705e51ca2c4c1fe3dda64
      libslirp: 4.6.1
      SLIRP_CONFIG_VERSION_MAX: 3
      libseccomp: 2.5.3
  swapFree: 7575957504
  swapTotal: 7578054656
  uptime: 15h 42m 53.52s (Approximately 0.62 days)
plugins:
  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/test179/.config/containers/storage.conf
  containerStore:
    number: 11
    paused: 0
    running: 4
    stopped: 7
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/test179/.local/share/containers/storage
  graphRootAllocated: 407822663680
  graphRootUsed: 362134671360
  graphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 168
  runRoot: /run/user/1090/containers
  volumePath: /home/test179/.local/share/containers/storage/volumes
version:
  APIVersion: 4.1.1
  Built: 1655914664
  BuiltTime: Wed Jun 22 18:17:44 2022
  GitCommit: ""
  GoVersion: go1.18.3
  Os: linux
  OsArch: linux/amd64
  Version: 4.1.1

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

podman-4.1.1-2.fc36.x86_64

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)

Yes

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

$ rpm -q crun
crun-1.5-1.fc36.x86_64
$ rpm -qi crun
Name        : crun
Version     : 1.5
Release     : 1.fc36
Architecture: x86_64
Install Date: Sun 24 Jul 2022 07:25:19 AM CEST
Group       : Unspecified
Size        : 436028
License     : GPLv2+
Signature   : RSA/SHA256, Wed 20 Jul 2022 10:12:25 PM CEST, Key ID 999f7cbf38ab71f4
Source RPM  : crun-1.5-1.fc36.src.rpm
Build Date  : Wed 20 Jul 2022 08:43:40 PM CEST
Build Host  : buildvm-x86-09.iad2.fedoraproject.org
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : https://github.com/containers/crun
Bug URL     : https://bugz.fedoraproject.org/crun
Summary     : OCI runtime written in C
Description :
crun is a runtime for running OCI containers
@openshift-ci openshift-ci bot added the kind/bug Categorizes issue or PR as related to a bug. label Jul 24, 2022
rhatdan added a commit to rhatdan/podman that referenced this issue Jul 24, 2022
Fixes containers#15049

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
rhatdan added a commit to rhatdan/podman that referenced this issue Jul 24, 2022
Fixes containers#15049

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
@vrothberg
Copy link
Member

Thanks for the report, @eriksjolund!

It's definitely a bug. Since @rhatdan is already working on it, I am assigning the issue to him.

rhatdan added a commit to rhatdan/podman that referenced this issue Jul 25, 2022
Fixes containers#15049

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
rhatdan added a commit to rhatdan/podman that referenced this issue Jul 25, 2022
Fixes containers#15049

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
rhatdan added a commit to rhatdan/podman that referenced this issue Jul 25, 2022
Fixes containers#15049

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
rhatdan added a commit to rhatdan/podman that referenced this issue Jul 25, 2022
Fixes containers#15049

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
rhatdan added a commit to rhatdan/podman that referenced this issue Jul 25, 2022
Fixes containers#15049

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
rhatdan added a commit to rhatdan/podman that referenced this issue Jul 26, 2022
Fixes containers#15049

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
rhatdan added a commit to rhatdan/podman that referenced this issue Jul 26, 2022
Fixes containers#15049

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
rhatdan added a commit to rhatdan/podman that referenced this issue Jul 28, 2022
Fixes containers#15049

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
mheon pushed a commit to mheon/libpod that referenced this issue Aug 10, 2022
Fixes containers#15049

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

<MH: Fixed cherry-pick conflicts>

Signed-off-by: Matthew Heon <mheon@redhat.com>
mheon pushed a commit to mheon/libpod that referenced this issue Aug 10, 2022
Fixes containers#15049

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

<MH: Fixed cherry-pick conflicts>

Signed-off-by: Matthew Heon <mheon@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 20, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 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.

3 participants