How to delete podman containers from deleted accounts?
Environment
- Red Hat Enterprise Linux 8
- Red Hat Enterprise Linux 9
- Red Hat Enterprise Linux 10
- podman
Issue
- uid from an organisation is retired but the container data is still present and occupies space on the host
Resolution
-
graphRoot is the location where podman data of the user is stored and runRoot is the location where the podman metadata for the user is stored. These need to be removed to get rid of the unwanted containers, volumes, images, etc. of the deleted user
-
Below steps can be followed to achieve the same
[quickcluster@node-0 ~]$ whoami
quickcluster
[quickcluster@node-0 ~]$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
registry.access.redhat.com/ubi8 latest b2ec169a404e 13 days ago 212 MB
[quickcluster@node-0 ~]$ podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e4efdd7f777e registry.access.redhat.com/ubi8:latest /bin/bash 2 minutes ago Up 2 minutes gifted_brown
[quickcluster@node-0 ~]$ podman volume ls
DRIVER VOLUME NAME
local vol-test
[quickcluster@node-0 ~]$ podman info | grep -i -e runroot -e graphroot
graphRoot: /home/quickcluster/.local/share/containers/storage
graphRootAllocated: 42832211968
graphRootUsed: 5195296768
runRoot: /run/user/1000/containers
[quickcluster@node-0 ~]$ sudo su -
Last login: Mon Sep 23 11:49:14 EDT 2024 on pts/1
[root@node-0 ~]# rm -rf /home/quickcluster/.local/share/containers/storage
[root@node-0 ~]# rm -rf /run/user/1000/containers
[root@node-0 ~]# exit
logout
[quickcluster@node-0 ~]$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
[quickcluster@node-0 ~]$ podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[quickcluster@node-0 ~]$ podman volume ls
Root Cause
- podman data for a user need not necessarily be removed when a user is invalid or removed from the organization profile; it needs to be removed manually
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments