RHCSA Container Fundamentals & Podman Management

Expertise in Cloud, Networking & DevOps
Photo by fabio / Unsplash

πŸ“Œ Introduction

Container technology has become an essential component of modern Linux system administration. In the RHCSA exam, you need to understand how to run, manage, and troubleshoot containers using Podman. Unlike Docker, Podman is a rootless container runtime, offering better security and compatibility with Red Hat-based distributions.


πŸ“– What You’ll Learn in This Guide

πŸ”Ή Understanding container fundamentals and how Podman works

πŸ”Ή Running and managing containers using Podman

πŸ”Ή Working with container images and storage

πŸ”Ή Managing persistent storage for containers

πŸ”Ή Troubleshooting common container issues


πŸ›  Understanding Podman & Containers

1️⃣ What is Podman?

Podman is a container management tool that provides a Docker-compatible CLI but runs containers without requiring a daemon (rootless by default). Key advantages include:

βœ” Daemonless architecture - No central service required.

βœ” Rootless execution - Enhanced security as containers run under a user account.

βœ” Full OCI compliance - Works with Open Container Initiative (OCI) images.

βœ” Supports Kubernetes integration - Can generate Kubernetes YAML files from containers.

To verify Podman is installed:

podman --version  # Check Podman version

If not installed, install it using:

sudo dnf install -y podman  # Install Podman on RHEL-based systems

πŸš€ Running & Managing Containers

1️⃣ Running a Simple Container

To run a container using an existing image:

podman run --rm -it alpine sh  # Run an Alpine Linux container interactively

Breaking down the command:

  • --rm β†’ Remove the container after it stops.
  • -it β†’ Interactive mode with a TTY.
  • alpine β†’ Use the Alpine Linux image.
  • sh β†’ Execute the shell inside the container.

To run a detached (background) container:

podman run -d --name webserver -p 8080:80 nginx
  • -d β†’ Run in detached mode.
  • --name webserver β†’ Assign a name to the container.
  • -p 8080:80 β†’ Map port 8080 on the host to port 80 in the container.
  • nginx β†’ Use the official nginx image.

To list running containers:

podman ps

To list all containers (including stopped ones):

podman ps -a

To stop a running container:

podman stop webserver

To remove a container:

podman rm webserver

πŸ” Best Practice: Use meaningful names for containers to avoid confusion when managing multiple instances.


πŸ–Ό Working with Container Images

1️⃣ Searching for Images

To search for an image from remote registries:

podman search ubuntu

2️⃣ Pulling Images

To download an image locally:

podman pull alpine

3️⃣ Listing Local Images

podman images  # Show available container images

4️⃣ Removing an Image

podman rmi alpine  # Remove the specified image

πŸ” Best Practice: Regularly remove unused images to save disk space.


πŸ“¦ Managing Persistent Storage for Containers

1️⃣ Creating a Volume

To create a persistent volume:

podman volume create mydata

To list available volumes:

podman volume ls

2️⃣ Mounting a Volume in a Container

podman run -d --name db_container -v mydata:/var/lib/mysql mariadb
  • -v mydata:/var/lib/mysql β†’ Mounts mydata volume to /var/lib/mysql in the container.
  • mariadb β†’ Runs a MariaDB database container.

To inspect volume details:

podman volume inspect mydata

3️⃣ Binding a Host Directory to a Container

Instead of using named volumes, you can mount a host directory:

podman run -d --name webserver -v /home/user/html:/usr/share/nginx/html:Z nginx
  • /home/user/html:/usr/share/nginx/html:Z β†’ Mounts host directory inside the container.
  • Z β†’ Corrects SELinux labels for container access.

πŸ” Best Practice: Use named volumes for data persistence, as bind mounts can introduce permission issues.


πŸ” Troubleshooting Common Container Issues

1️⃣ Checking Container Logs

podman logs webserver  # View logs of a container

2️⃣ Entering a Running Container

podman exec -it webserver sh  # Access a running container's shell

3️⃣ Inspecting a Container's Details

podman inspect webserver  # View container metadata

4️⃣ Cleaning Up Unused Containers & Images

podman system prune -a  # Remove unused containers, images, and volumes

πŸ” Best Practice: Regularly check logs and inspect running containers to ensure smooth operations.


πŸ›  Essential Practice for RHCSA

βœ… Install and configure Podman for container management.

βœ… Pull, run, and manage containers efficiently.

βœ… Work with container storage (volumes and bind mounts).

βœ… Troubleshoot container issues using logs, exec, and inspect.

βœ… Optimize storage and remove unused images and containers.


πŸ“Œ Next Article: RHCSA SELinux & System Security

πŸ“© Subscribe to our blog for more RHCSA tutorials and updates! πŸš€

Read more