Hands-on guide to container management using Podman and Docker compatible CLI commands covering installation, pulling images, running and naming containers, port mapping, stopping and cleaning images.
Hello — this lesson demonstrates practical container management and configuration using Docker-compatible tooling (Podman on RHEL-based systems). We’ll cover why containers are useful, how to install and configure Podman, and basic workflows: pulling images, running containers, mapping ports, stopping/removing containers, and cleaning up images.
Why use containers?
Containers package an application and everything it needs (binaries, libraries, configuration, logs, and data) together. This eliminates fragmented configurations across /etc, /var/lib, /var/log, etc., and makes migration or replication to other hosts predictable and repeatable.
Example: A MariaDB server inside a container keeps the daemon, configuration files, databases, and logs together. Copy or pull that container on another host and it behaves the same way.
Installing Docker-compatible tooling
On modern RHEL-based distributions (CentOS Stream, RHEL) Docker packages may not be available; Podman is the recommended replacement. Podman is daemonless, OCI-compliant, and provides Docker-compatible CLI behavior via the podman-docker wrapper.
Install Podman with dnf:
Copy
sudo dnf install podman
The podman-docker package provides docker CLI compatibility so many existing Docker commands (docker pull, docker run, docker ps, etc.) work unchanged.
Podman includes a Docker-CLI compatibility wrapper (podman-docker). You can use docker ... commands, or call podman directly. Podman is daemonless and integrates with systemd and rootless workflows.
Configuring default registries (optional)
Container tools consult /etc/containers/registries.conf to determine search registries for unqualified image names. To prefer docker.io only, set the unqualified-search-registries array to [“docker.io”].
Example excerpt from /etc/containers/registries.conf:
Copy
# An array of host[:port] registries to try when pulling an unqualified image, in order.unqualified-search-registries = ["docker.io"]
Suppress the informational docker wrapper message by creating the marker file:
Copy
sudo touch /etc/containers/no-docker
Working with images and containers (nginx walkthrough)
Below is a practical workflow for finding, pulling, running, testing, and cleaning up an nginx container using the Docker-compatible CLI. Replace docker with podman if you prefer explicit Podman commands.Search for nginx images in the registry:
Copy
docker search nginx
Pull the official nginx image (long and short forms both work):
REPOSITORY TAG IMAGE ID CREATED SIZEdocker.io/library/nginx latest 12766a6745ee 17 hours ago 146 MBdocker.io/library/nginx 1.20.2 8f34c303855f 17 hours ago 146 MB
docker rmi fails if an image is in use by any container. Preferred safe removal sequence:
Stop containers: docker stop <container>
Remove containers: docker rm <container>
Remove image: docker rmi <image>
Naming containers and exposing ports
Assign a name and publish ports with —name and -p HOST:CONTAINER. Example: run nginx named mywebserver with host port 8080 mapped to container port 80:
Copy
docker run -d -p 8080:80 --name mywebserver nginx# Example returned container ID:# 7953475436b9...
Testing the web server with netcat
Use netcat (nc) to query the server. Pass host and port as separate arguments (no colon):
Copy
nc localhost 8080GET /
You should receive the nginx default index.html content:
Copy
<!DOCTYPE html><html><head><title>Welcome to nginx!</title>...</html>
Press Ctrl+C to exit nc.
Ports below 1024 are privileged. To bind host port 80 to a container, run the command with elevated privileges (sudo) or map a non-privileged host port (>=1024).
Binding to privileged port 80 (example):
Copy
sudo docker run -d -p 80:80 --name mywebserver nginx
Getting help and Podman-specific options
Get detailed help for any command with —help:
Copy
docker run --helpdocker rm --help# orpodman run --help
Podman rm options (example excerpt):
Copy
podman rm [options] CONTAINER [CONTAINER...]Examples: podman rm imageID podman rm mywebserver myflaskserver 860a4b23 podman rm --force --all podman rm -f c684f0d469f2Options: -a, --all Remove all containers -f, --force Force removal of a running or unusable container -v, --volumes Remove anonymous volumes associated with the container -t, --time uint Seconds to wait for stop before killing the container (default 10) ...
Quick reference: common Docker/Podman commands
Action
Command
Search registry
docker search <term>
Pull image
docker pull \<image>
List local images
docker images
Run container (foreground)
docker run \<image>
Run detached
docker run -d -p <host>:\<container> --name <name> \<image>
This concludes the short hands-on introduction to pulling images, running containers, mapping ports, and cleaning up images. Practice these commands in a lab environment to build confidence and reinforce container lifecycle management.