Using Podman Quadlet on CentOS Stream 9: Managing Containers with Systemd

CentOS tutorial - IT technology blog
CentOS tutorial - IT technology blog

The Problem: When Containers Need to Run Like System Services

I recently finished migrating several legacy CentOS 7 servers at work over to AlmaLinux. As we moved services onto CentOS Stream 9 and RHEL 9, we also started containerizing our smaller web apps with Podman instead of installing them directly on the host. Spinning up a test instance with podman run takes less than 10 seconds. Once you move to production, though, a real question comes up: if the server reboots overnight or the app crashes mid-flight, what brings it back up?

In the past, sysadmins typically relied on podman generate systemd to export a .service file. Since Podman 4.4, however, that command has been deprecated—and for good reason. The generated service files are often 80–120 lines long, packed with hardcoded flags and container IDs. Anytime you need to change an environment variable, mount another volume, or bump an image tag, you have to edit the file by hand (which is error-prone) or regenerate it from scratch.

Podman solves this with Quadlet. Instead of wrestling with bloated unit files, you write a concise 10–15 line config file and let systemd handle the rest.

What Is Podman Quadlet and How Does It Work Under the Hood?

Simply put, you no longer have to craft complex .service files to tell systemd how to invoke Podman. You just create short declarative files with extensions like .container, .volume, .network, or .pod.

Behind the scenes, Quadlet works in three steps:

  • When you run systemctl daemon-reload, the generator binary at /usr/libexec/podman/quadlet scans your configuration directories.
  • It translates your .container files into standard .service units in memory (under /run/systemd/generator for rootful containers, or /run/user/<UID>/systemd/generator for rootless ones).
  • From there, you can manage them with systemctl start/stop, inspect logs via journalctl, and order startup dependencies just like any native system service.

Depending on whether you run containers as root (rootful) or as a regular user (rootless—recommended to reduce security risks), place your files in the corresponding directory:

  • Rootful (system-wide): /etc/containers/systemd/
  • Rootless (per-user): ~/.config/containers/systemd/

Hands-On: Deploying Rootless Nginx on CentOS Stream 9

Below is a practical setup for running Nginx in rootless mode on CentOS Stream 9. The container will use a dedicated network, persist data in a volume, and start automatically whenever the server boots.

Step 1: Check Your Podman Version

CentOS Stream 9 currently ships with Podman 4.9 or newer (or the 5.x branch on recent updates), which includes Quadlet out of the box. Open a terminal and verify:

cat /etc/redhat-release
sudo dnf install -y podman
podman --version

Anything from podman version 4.4.0 and up (for example, 4.9.4) works right away with no extra packages needed.

Step 2: Create the Config Directory, Network, and Volume

As a regular user, create the standard Quadlet directory inside your home folder:

mkdir -p ~/.config/containers/systemd

Instead of creating networks and volumes separately via the CLI, declare them in Quadlet files so systemd creates them automatically if they don’t exist yet. Create ~/.config/containers/systemd/web-net.network:

[Unit]
Description=Internal network for web applications

[Network]
Driver=bridge

Next, create ~/.config/containers/systemd/web-data.volume to keep your web data intact when the container is removed or upgraded:

[Unit]
Description=Volume for Nginx data storage

[Volume]

Step 3: Write the .container File for Nginx

Create ~/.config/containers/systemd/nginx-demo.container with just 15 lines:

[Unit]
Description=Nginx Web Server managed by Podman Quadlet
After=network-online.target

[Container]
Image=docker.io/library/nginx:alpine
ContainerName=nginx-demo
PublishPort=8080:80
Network=web-net.network
Volume=web-data.volume:/usr/share/nginx/html:Z
AutoUpdate=registry

[Service]
Restart=always
TimeoutStartSec=90

[Install]
WantedBy=default.target

Here are six key directives in that file worth noting:

  • PublishPort=8080:80: Unprivileged Linux users cannot bind to privileged ports below 1024 (like 80 or 443), so we map host port 8080 to container port 80.
  • The :Z suffix on Volume: CentOS Stream 9 enables SELinux in enforcing mode by default. Adding :Z tells Podman to apply a private SELinux label to the volume so Nginx doesn’t hit Permission Denied errors.
  • Network=web-net.network and Volume=web-data.volume: Quadlet automatically recognizes the two files from Step 2 and provisions them before starting the container.
  • AutoUpdate=registry: Marks the container so podman auto-update (or podman-auto-update.timer) can automatically pull newer images when updates are published.
  • TimeoutStartSec=90: Gives systemd up to 90 seconds to pull the image on the first start so a slow connection won’t cause a premature timeout.
  • [Install] with WantedBy=default.target: Because Quadlet-generated units live ephemerally in /run, you can’t run systemctl enable on them. This section tells Quadlet to enable the service automatically during daemon reload.

Step 4: Reload Systemd and Start the Service

Once the files are saved, tell systemd to reload its configuration and start the container:

systemctl --user daemon-reload
systemctl --user start nginx-demo.service
systemctl --user status nginx-demo.service

Verify that Nginx is responding on port 8080:

curl -I http://localhost:8080

If you see HTTP/1.1 200 OK, you’re good to go. To follow the logs in real time, use journalctl:

journalctl --user -u nginx-demo.service -f

Don’t skip this step for rootless setups: by default on CentOS Stream 9, all --user services stop as soon as you close your SSH session, and they won’t start at boot unless you log in. Enable linger for your user account:

sudo loginctl enable-linger $USER

Step 5: Validate Syntax Before Reloading

When managing multiple containers, typos in directive names happen. Instead of reloading and hunting through logs, run the Quadlet generator in dry-run mode first:

/usr/libexec/podman/quadlet -dryrun -user

This prints out the full generated .service unit and pinpoints any syntax errors.

Wrapping Up

For single-server deployments running a handful of services, Podman Quadlet on CentOS Stream 9 is far cleaner than the old workflow. No more hundred-line, hard-to-maintain unit files from podman generate systemd, and no need to stand up heavy orchestrators before you actually need them.

Your entire setup lives in a few short text files that you can commit straight to Git for version control. If you’re planning to migrate services from CentOS 7 to RHEL 9 or CentOS Stream 9, try moving one or two small services to Quadlet first—you’ll see the difference right away.

Share: