To run a command in a running container and investigate that container, you can use the podman exec command. The reason for using the podman exec command instead of the podman run command is that you can investigate the running container without interrupting the container activity.
Before you begin
- The
container-tools meta-package is installed.
- The container is running.
Procedure
-
Enter the
rpm -qa command inside the my-support-tools container to list all installed packages:
$ podman exec -it my-support-tools rpm -qa
gpg-pubkey-fd431d51-4ae0493b
gpg-pubkey-5a6340b3-6229229e
libgcc-11.5.0-2.el9.x86_64
setup-2.13.7-10.el9.noarch
...
-
Enter a
/bin/bash command in the my-support-tools container:
$ podman exec -it my-support-tools /bin/bash
-
Install the
procps-ng package containing a set of system utilities (for example ps, top, uptime, and so on):
-
Inspect the container:
- To list every process on the system:
UID PID PPID C STIME TTY TIME CMD
root 8 0 0 11:07 pts/0 00:00:00 /bin/bash
root 47 8 0 11:13 pts/0 00:00:00 ps -ef
- To display file system disk space usage:
Filesystem Size Used Avail Use% Mounted on
tmpfs 6.3G 448K 6.3G 1% /etc/hosts
shm 63M 0 63M 0% /dev/shm
overlay 953G 76G 877G 8% /
tmpfs 64M 0 64M 0% /dev
devtmpfs 4.0M 0 4.0M 0% /dev/tty
...
- To display system information:
6.12.0-124.15.1.el10_1.x86_64
- To display amount of free and used memory in megabytes:
total used free shared buff/cache available
Mem: 2818 615 1183 12 1020 1957
Swap: 3124 0 3124