Posted on :: 327 Words :: Tags: , ,

Podman Quadlets provide a modern approach to managing containers as systemd services. This integration allows for better container lifecycle management and automated startup on boot. Unlike traditional container management methods, Quadlets offer a more standardized and system-integrated way to handle containers.

What are Quadlets?

Quadlets are configuration files that define how containers should run as systemd services. They combine the simplicity of systemd unit files with Podman's container management capabilities, offering:

  • Automatic container startup on system boot
  • Integrated logging with journald
  • Dependency management through systemd
  • Clean service management interface

Pre-requisites

  • Podman installed on your system
  • systemd as init system
  • Basic understanding of systemd services

When using rootless podman, you need to create a specific directory structure:

mkdir -p ~/.config/containers/systemd

With rootfull podman the directory is under /etc/containers/systemd.

This directory will store your Quadlet configuration files.

Implementing Quadlets

Quadlet files for Pods must follow these rules:

  • File extension must be .kube
  • Located in ~/.config/containers/systemd
  • Follow systemd unit file syntax

Here's an example Quadlet configuration for running Home Assistant:

[Install]
WantedBy=default.target

[Unit]
Description=Home Assistant Container
After=network-online.target

[Kube]
Yaml=/opt/container/homeassistant/kube.yaml
Network=proxy

[Service]
Restart=always
TimeoutStartSec=900
  1. [Install]: Defines when the service should start
  2. [Unit]: Contains metadata and dependencies
  3. [Kube]: Specifies the Kubernetes YAML file location
  4. [Service]: Defines service behavior

All the options for the quadlet file can be found in the podman documentation.

Managing Quadlets

Starting the Service

After creating your Quadlet file, enable and start the service:

# Reload systemd to recognize new service
systemctl --user daemon-reload

# Start the service
systemctl --user start homeassistant

Monitoring and Troubleshooting

View container logs using either Podman or systemd:

# View status of systemd service
systemctl --user status -u homeassistant

# View container logs through Podman
podman pod logs homeassistant

# View service logs through systemd
journalctl --user -u homeassistant