Skip to content

Force removing image with 2 tags and running container does not remove the container #7153

@marusak

Description

@marusak

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

/kind bug

Description
Force removing image with 2 tags and running container does not remove the container.
I created simple script, see below. The first rmi call fails, calling it again succeeds, removes both images but keeps the container running. The container cannot be then inspected nor attached to, but is still shown as running.
If I don't tag the container (removing the third line in the script) the first removal succeeds and all is as expected.

Steps to reproduce the issue:

$ cat script1.sh 
podman pull docker.io/library/fedora:latest
id=`podman inspect --format '{{.Id}}' docker.io/library/fedora:latest`
podman tag docker.io/library/fedora:latest docker.io/library/fedora:32
podman run -dt docker.io/library/fedora:latest bash

podman rmi -f $id
sleep 5
podman rmi -f $id

podman images -a
podman ps -a

$ sudo podman ps -a
CONTAINER ID  IMAGE                 COMMAND  CREATED      STATUS   PORTS                                           NAMES
597b71ce3dab  k8s.gcr.io/pause:3.1           4 weeks ago  Created  0.0.0.0:80->5000/tcp, 0.0.0.0:27017->27017/tcp  31f255dd9f21-infra

$ sudo podman images -a
REPOSITORY               TAG     IMAGE ID      CREATED      SIZE
docker.io/library/mongo  latest  2b2cc1f48aed  6 weeks ago  392 MB
k8s.gcr.io/pause         3.1     da86e6ba6ca1  2 years ago  749 kB

$ sudo ./script1.sh
Trying to pull docker.io/library/fedora:latest...
Getting image source signatures
Copying blob c7def56d621e done  
Copying config a368cbcfa6 done  
Writing manifest to image destination
Storing signatures
a368cbcfa6789bc347345f6d19132afe138b62ff5373d2aa5f37120277c90b54
3fd9dfa4eda0dacc53d4120d4e6a97c784ead84d4a27a3bcb24c4208a7c1e6aa
Error: 1 error occurred:
	* error removing containers [e3f852c3b57d68017969518e70c4a8dd558da0ef5d11a0f75e43eced8e9aa098] for image "a368cbcfa6789bc347345f6d19132afe138b62ff5373d2aa5f37120277c90b54": could not remove container "e3f852c3b57d68017969518e70c4a8dd558da0ef5d11a0f75e43eced8e9aa098": 2 errors occurred:
	* unlinkat /var/lib/containers/storage/overlay-containers/e3f852c3b57d68017969518e70c4a8dd558da0ef5d11a0f75e43eced8e9aa098/userdata/shm: device or resource busy
	* unlinkat /var/lib/containers/storage/overlay-containers/e3f852c3b57d68017969518e70c4a8dd558da0ef5d11a0f75e43eced8e9aa098/userdata/shm: device or resource busy
Untagged: docker.io/library/fedora:latest
Untagged: docker.io/library/fedora:32
Deleted: a368cbcfa6789bc347345f6d19132afe138b62ff5373d2aa5f37120277c90b54
REPOSITORY               TAG     IMAGE ID      CREATED      SIZE
docker.io/library/mongo  latest  2b2cc1f48aed  6 weeks ago  392 MB
k8s.gcr.io/pause         3.1     da86e6ba6ca1  2 years ago  749 kB
CONTAINER ID  IMAGE                            COMMAND  CREATED        STATUS            PORTS                                           NAMES
3fd9dfa4eda0  docker.io/library/fedora:latest  bash     5 seconds ago  Up 5 seconds ago                                                  admiring_golick
597b71ce3dab  k8s.gcr.io/pause:3.1                      4 weeks ago    Created           0.0.0.0:80->5000/tcp, 0.0.0.0:27017->27017/tcp  31f255dd9f21-infra

Describe the results you received:
Container is still running even though its image is not present.

Describe the results you expected:
Container would be deleted the same way it gets deleted when the image has only one tag.

Output of podman version:

Version:      2.0.2
API Version:  1
Go Version:   go1.14.3
Built:        Thu Jan  1 01:00:00 1970
OS/Arch:      linux/amd64

NOTE:
I noticed this when I was force deleting through APIv2. There it should behave the same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.locked - please file new issue/PRAssist humans wanting to comment on an old issue or PR with locked comments.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions