5.3. Running commands inside the container
Use the podman run command to run a container interactively.
Prerequisites
-
The
container-toolsmeta-package is installed.
Procedure
Run the container named
myubibased on theregistry.redhat.io/ubi10/ubiimage:$ podman run --name=myubi -it registry.access.redhat.com/ubi10/ubi /bin/bash [root@6ccffd0f6421 /]#-
The
-ioption creates an interactive session. Without the-toption, the shell stays open, but you cannot type anything to the shell. -
The
-toption opens a terminal session. Without the-ioption, the shell opens and then exits.
-
The
Install the
procps-ngpackage containing a set of system utilities (for exampleps,top,uptime, and so on):[root@6ccffd0f6421 /]# dnf install procps-ngUse the
ps -efcommand to list current processes:# ps -ef UID PID PPID C STIME TTY TIME CMD root 1 0 0 12:55 pts/0 00:00:00 /bin/bash root 31 1 0 13:07 pts/0 00:00:00 ps -efEnter
exitto exit the container and return to the host:# exitOptional: List all containers:
$ podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1984555a2c27 registry.redhat.io/ubi10/ubi:latest /bin/bash 21 minutes ago Exited (0) 21 minutes ago myubiYou can see that the container is in Exited status.