Cloud Native 6 min read

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.

Liangxu Linux
Liangxu Linux
Liangxu Linux
How to Quickly Set Up a Podman Environment on CentOS 8

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 = 28633

Run 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 nano

Build 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 images

Run the New Image

Check that nano is available inside the container:

# podman run localhost/ubi-with-nano /usr/bin/which nano
/usr/bin/nano

Start 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 -a

Persist 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 podman

The file written inside the container persists on the host after the container stops.

Podman environment setup screenshot
Podman environment setup screenshot
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxContainerstorageDockerfileCentOSPodman
Liangxu Linux
Written by

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.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.