podman-q...ic-usage(7)

πŸ“¦ version 6.1.4, in arch rolling, centos-stream 10, nixpkgs unstable

✨ NAME ✨

okay so this is podman-quadlet-basic-usage β€” the basic usage examples and step-by-step guide for Podman Quadlet. We’re in the podman-q...ic-usage(7) manual, aka the Miscellaneous Information Manual, and it’s literally your little Quadlet cheat sheet. πŸ¦‹

πŸ’– DESCRIPTION πŸ’–

This guide introduces common usage patterns for Podman Quadlet. It gives you step-by-step examples for defining containers, exposing ports, creating volumes, and establishing dependencies using declarative .container, .volume, and related unit files.

Quadlet simplifies container lifecycle management by translating these files into systemd services, making them manageable with systemctl. That’s the whole slay: you write files, systemd gets services. ✨

🌈 EXAMPLE 1: RUNNING A SIMPLE CONTAINER 🌈

πŸŽ€ Step 1: Create hello.container πŸŽ€

[Unit]
Description=Hello Alpine Container

[Container]
Image=alpine
Exec=echo Hello from Quadlet!

[Install]
WantedBy=multi-user.target

πŸŽ€ Step 2: Place the file πŸŽ€

For rootless use:

mkdir -p ~/.config/containers/systemd
cp hello.container ~/.config/containers/systemd/

For rootful use:

sudo cp hello.container /etc/containers/systemd/

πŸŽ€ Step 3: Reload and start the service πŸŽ€

For rootless use:

systemctl --user daemon-reload
systemctl --user start hello.service

For rootful use:

sudo systemctl daemon-reload
sudo systemctl start hello.service
⚠️ note: Quadlet services cannot be enabled as they are a generated systemd unit, see podman-systemd.unit(5) for more information. no cap, this matters. πŸ’…

🌟 Expected Output: 🌟

For rootless, check logs using:

journalctl --user -u hello.service

For rootful:

journalctl -u hello.service

You should see: Hello from Quadlet!

That means the container started, executed the echo command, and exited. iconic. πŸ’–

πŸ“ EXAMPLE 2: CREATING A NAMED VOLUME πŸ“

πŸŽ€ Step 1: Create mydata.volume πŸŽ€

[Volume]
VolumeName=mydata
Label=purpose=demo

πŸŽ€ Step 2: Place and reload πŸŽ€

For rootless use:

mkdir -p ~/.config/containers/systemd
cp mydata.volume ~/.config/containers/systemd/
systemctl --user daemon-reload

For rootful use:

sudo cp mydata.volume /etc/containers/systemd/
sudo systemctl daemon-reload

πŸŽ€ Step 3: Create the volume πŸŽ€

For rootless use:

systemctl --user start mydata-volume.service

For rootful use:

systemctl start mydata-volume.service

πŸ¦‹ EXAMPLE 3: CONTAINER USING A VOLUME πŸ¦‹

πŸŽ€ Create with-volume.container πŸŽ€

[Unit]
Description=Container with Mounted Volume

[Container]
Image=alpine
Exec=sh -c "ls /data && echo Hello > /data/hello.txt"
Volume=mydata.volume:/data

[Install]
WantedBy=multi-user.target

This container lists all files in the volume and creates hello.txt. lowkey neat.

πŸŽ€ Start the container and check the status πŸŽ€

For rootless use:

cp with-volume.container ~/.config/containers/systemd/
systemctl --user daemon-reload
systemctl --user start with-volume.service
systemctl --user status with-volume.service

For rootful use:

sudo cp with-volume.container /etc/containers/systemd/
sudo systemctl daemon-reload
sudo systemctl start with-volume.service
sudo systemctl status with-volume.service

When started for the first time, the hello.txt will not appear in the systemctl status output, because it has not been created yet. But when started for the second time, the output will be:

hello.txt

This means the volume is used and is persistent. periodt. πŸ’…

🌸 EXAMPLE 4: EXPOSING A CONTAINER PORT TO THE HOST 🌸

πŸŽ€ Create webserver.container πŸŽ€

[Unit]
Description=Nginx Webserver

[Container]
Image=nginx:alpine
PublishPort=8080:80

[Install]
WantedBy=multi-user.target

πŸŽ€ Start the web server πŸŽ€

For rootless use:

cp webserver.container ~/.config/containers/systemd/
systemctl --user daemon-reload
systemctl --user start webserver.service

For rootful use:

sudo cp webserver.container /etc/containers/systemd/
sudo systemctl daemon-reload
sudo systemctl start webserver.service

Visit http://localhost:8080 in your browser. she’s serving. πŸ‘‘

πŸ’‘ TIPS πŸ’‘

To start a container on system boot, use:

[Install]
WantedBy=multi-user.target

If systemctl cannot find foo.service, it usually means there is a syntax error in your Quadlet file. To find the details, use:

systemd-analyze --user --generators=true verify foo.service

πŸ‘€ SEE ALSO πŸ‘€

🫢 AUTHORS 🫢


okay that’s the whole podman-q...ic-usage(7) page, bestie β€” source/version is the <pink>podman-q...ic-usage(7)</pink> manual from the Miscellaneous Information Manual, and there’s no date stamp printed in this copy, so we’re not inventing one. mwah, go run some Quadlet units. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from