Running Containers
Now that you understand what containers are, it is time to run one. This page walks through the most common Podman commands you will use day to day.
Running a container
Section titled “Running a container”The podman run command pulls an image and starts a container from it. Try it with the hello-world image:
$ podman run hello-worldPodman downloads the image, creates a container, runs it, and prints a welcome message. The container then stops on its own.
You can also run a full operating system image like Ubuntu:
$ podman run ubuntu:24.04This pulls Ubuntu 24.04, starts a container, and exits immediately. It exits because no command was given for the container to run. The next section shows how to keep it open.
Interactive mode
Section titled “Interactive mode”Use -it to start a container and get a shell inside it:
$ podman run -it ubuntu:24.04 bashThe -i flag keeps standard input open. The -t flag allocates a terminal. Together they give you an interactive session inside the container.
Once inside, you can explore the container’s file system:
root@a1b2c3d4e5f6:/# ls /root@a1b2c3d4e5f6:/# cat /etc/os-releaseroot@a1b2c3d4e5f6:/# exitTyping exit stops the container and returns you to your host terminal.
Running a command and exiting
Section titled “Running a command and exiting”Sometimes you want to run a single command and clean up afterward. The --rm flag removes the container automatically after it stops:
$ podman run --rm ubuntu:24.04 echo "hello from the container"Without --rm, stopped containers remain on disk. They accumulate over time and waste space. Using --rm is a good habit for one-off commands.
Running bioinformatics tools
Section titled “Running bioinformatics tools”BioContainers provides pre-built images for thousands of bioinformatics tools. You do not need to install anything on your host system. Just pull and run.
Check the version of samtools:
$ podman run --rm biocontainers/samtools:v1.17.0_cv1 samtools --versionRun FastQC on a FASTQ file:
$ podman run --rm -v $(pwd):/data biocontainers/fastqc:v0.12.1_cv1 fastqc /data/reads.fastq.gzThe -v flag mounts your current directory into the container. This lets the tool access your files. Volumes are covered in detail in the next chapter.
Background containers
Section titled “Background containers”Some containers need to run continuously. An RStudio Server instance is a good example. Use -d to run in detached mode:
$ podman run -d -p 8787:8787 -e PASSWORD=mypassword rocker/rstudio:latestThe -d flag runs the container in the background. The -p flag maps port 8787 on your host to port 8787 in the container. You can then open http://localhost:8787 in your browser.
Podman prints the container ID when it starts in detached mode. You will use this ID to manage the container.
Listing containers
Section titled “Listing containers”To see all running containers:
$ podman psTo see all containers, including stopped ones:
$ podman ps -aThe output shows each container’s ID, image, status, and name. Podman assigns a random name if you do not provide one. You can set a name with --name:
$ podman run -d --name rstudio -p 8787:8787 -e PASSWORD=mypassword rocker/rstudio:latestStopping and removing containers
Section titled “Stopping and removing containers”Stop a running container by name or ID:
$ podman stop rstudioThis sends a graceful shutdown signal. The container has 10 seconds to stop before Podman forces it to stop.
Remove a stopped container:
$ podman rm rstudioTo force-remove a running container in one step:
$ podman rm -f rstudioTo remove all stopped containers at once:
$ podman container pruneViewing logs
Section titled “Viewing logs”Containers write their standard output and standard error to a log. View it with podman logs:
$ podman logs rstudioTo follow the log in real time, add -f:
$ podman logs -f rstudioThis is useful for debugging. If a bioinformatics tool fails inside a container, the error message will be in the logs.
Executing commands in a running container
Section titled “Executing commands in a running container”You can open a shell inside a container that is already running. This is helpful for inspecting files or debugging:
$ podman exec -it rstudio bashThe exec command runs a new process inside an existing container. The -it flags work the same as with podman run. They give you an interactive terminal.
You can also run a single command without opening a full shell:
$ podman exec rstudio ls /home/rstudioQuick reference
Section titled “Quick reference”| Command | Description |
|---|---|
podman run image |
Run a container from an image |
podman run -it image bash |
Run interactively with a shell |
podman run --rm image cmd |
Run and remove after exit |
podman run -d image |
Run in the background |
podman run -v host:container |
Mount a host directory |
podman ps |
List running containers |
podman ps -a |
List all containers |
podman stop name |
Stop a container |
podman rm name |
Remove a stopped container |
podman rm -f name |
Force-remove a container |
podman logs name |
View container logs |
podman exec -it name bash |
Open a shell in a running container |
Next steps
Section titled “Next steps”You now know how to run, inspect, and manage containers. The next chapter covers Volumes and Networking, where you will learn how to share data between your host and containers.