Skip to main content
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.
A dark presentation slide reading "Demo — Manage and configure containers" with a small film-camera icon in the center-right and a "KodeKloud" logo in the top-right corner.
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:
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:
# 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:
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:
docker search nginx
Pull the official nginx image (long and short forms both work):
docker pull docker.io/library/nginx
# or
docker pull nginx
Example pull output (truncated):
Trying to pull docker.io/library/nginx:latest...
Getting image source signatures
Copying blob c4ffe9532b5f done
Copying blob 2215908dc0a2 done
Copying config 12766a6745 done
Writing manifest to image destination
Storing signatures
12766a6745eea133de9fdcd03ff720fa971fdaf2
[aaron@LFCS-CentOS ~]$
List images available locally:
docker images
Example:
REPOSITORY                 TAG       IMAGE ID       CREATED         SIZE
docker.io/library/nginx    latest    12766a6745ee   17 hours ago    146 MB
docker.io/library/nginx    1.20.2    8f34c303855f   17 hours ago    146 MB
Remove an older image tag:
docker rmi nginx:1.20.2
Example output:
Untagged: docker.io/library/nginx:1.20.2
Deleted: 8f34c303855f0e55ca018386ff45cf47b1d7da554ab746b1c60049ebcf12d42c
[aaron@LFCS-CentOS ~]$
Creating and running containers
  • By default, running without -d attaches your terminal to the container’s stdout/stderr. Use Ctrl+C to stop.
Run in the foreground (attached):
docker run nginx
Run detached (background):
docker run -d nginx
# outputs container ID, e.g.:
# 92a87f978de3...
List running containers:
docker ps
List all containers (running and stopped):
docker ps --all
Stop and remove containers:
docker stop <container-name-or-id>
docker rm <container-name-or-id>
Notes on safe image removal:
  • docker rmi fails if an image is in use by any container. Preferred safe removal sequence:
    1. Stop containers: docker stop <container>
    2. Remove containers: docker rm <container>
    3. 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:
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):
nc localhost 8080
GET /
You should receive the nginx default index.html content:
<!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):
sudo docker run -d -p 80:80 --name mywebserver nginx
Getting help and Podman-specific options
  • Get detailed help for any command with —help:
docker run --help
docker rm --help
# or
podman run --help
Podman rm options (example excerpt):
podman rm [options] CONTAINER [CONTAINER...]

Examples:
  podman rm imageID
  podman rm mywebserver myflaskserver 860a4b23
  podman rm --force --all
  podman rm -f c684f0d469f2

Options:
  -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
ActionCommand
Search registrydocker search <term>
Pull imagedocker pull \<image>
List local imagesdocker images
Run container (foreground)docker run \<image>
Run detacheddocker run -d -p <host>:\<container> --name <name> \<image>
List running containersdocker ps
List all containersdocker ps --all
Stop containerdocker stop \<container>
Remove containerdocker rm \<container>
Remove imagedocker rmi \<image>
Links and references 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.

Watch Video