How to Quickly Set Up a Podman Environment on CentOS 8
This guide walks you through installing Podman on CentOS 8, configuring user namespaces, creating and building a custom UBI‑based image with a Dockerfile, running containers, verifying installed tools, using interactive shells, and mounting host directories for persistent storage.
Install Podman
On a CentOS 8 host, install the Podman container runtime: # yum -y install podman Adjust the user namespace limit to allow enough namespaces:
# echo "user.max_user_namespaces=28633" >> /etc/sysctl.d/userns.conf
# sysctl -p /etc/sysctl.d/userns.conf
# user.max_user_namespaces = 28633Run a Test Container
Verify Podman works by pulling and inspecting the Red Hat UBI image: # podman run ubi8/ubi cat /etc/os-release The command outputs the OS details of the UBI image, confirming the pull succeeded.
Create a Dockerfile
Prepare a directory for the Dockerfile and build a custom image that includes the nano editor:
# mkdir ~/myc
# cd ~/myc
# vim Dockerfile
FROM ubi8/ubi:latest
RUN dnf install -y nanoBuild the Custom Image
Build the image and tag it ubi-with-nano:
# podman build -f Dockerfile -t ubi-with-nano
STEP 1/2: FROM ubi8/ubi:latest
STEP 2/2: RUN dnf install -y nano
... (build output)List images to confirm the new image exists:
# podman imagesRun the New Image
Check that nano is available inside the container:
# podman run localhost/ubi-with-nano /usr/bin/which nano
/usr/bin/nanoStart an interactive shell:
# podman run -it localhost/ubi-with-nano /bin/bash
[root@container /]# ls
... (list of directories)Exit the container with exit.
Manage Containers
List running containers: # podman ps List all containers, including stopped ones:
# podman ps -aPersist Data with a Bind Mount
Create a host directory to store persistent data: # mkdir /pod_data Run a container binding /pod_data on the host to /storage inside the container (SELinux context :Z):
# podman run -it --volume /pod_data:/storage:Z localhost/ubi-with-nano
[root@container /]# echo "hello podman" >> /storage/msg.txt
[root@container /]# exit
# cat /pod_data/msg.txt
hello podmanThe file written inside the container persists on the host after the container stops.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
