Rootless Container Management with Podman
Podman is a daemonless, OCI-compliant container engine for Linux that allows regular, non-root users to run rootless containers using user namespaces without requiring a privileged daemon.
1. Registry Search and Image Management
# Search for images in configured registries (/etc/containers/registries.conf)
podman search ubi9
# Pull container image
podman pull registry.access.redhat.com/ubi9/ubi-micro:latest
# List local downloaded images
podman images
2. Running Rootless Containers
# Run detached container with custom name and port publishing
podman run -d --name webapp -p 8080:80 \
-v /home/student/site:/usr/share/nginx/html:Z \
registry.redhat.io/rhel9/nginx-120
[!IMPORTANT] The Critical SELinux
:ZVolume Flag: When bind-mounting a host directory into a container, SELinux blocks container access by default. Appending:Zrelabels the host storage exclusively for that container (container_file_t). Appending:zshares the context among multiple containers.
3. High-Yield Task: Managing Containers as systemd Services
On the RHCSA exam, containers must start automatically upon system boot as a non-privileged user.
Step 1: Enable Linger for the User
By default, user services terminate when the user logs out. Linger allows background user processes and systemd instances to persist after logout and start on boot:
loginctl enable-linger student
loginctl show-user student | grep Linger
Step 2: Generate systemd User Unit
# Create local systemd user directory
mkdir -p ~/.config/systemd/user
cd ~/.config/systemd/user
# Generate systemd unit file from existing container
podman generate systemd --name webapp --files --new
# Reload systemd user daemon
systemctl --user daemon-reload
# Enable and start user service
systemctl --user enable --now container-webapp.service
# Verify service state
systemctl --user status container-webapp.service
Cross-references:
- See systemd Service, Target, and Timer Management for systemd service and unit concepts.
- See Security-Enhanced Linux (SELinux) Mandatory Access Controls for SELinux container volume labels.