Table of Contents

Podman

Podman manages containers like Docker and Kubernetes.

Use with systemd

generic service

Generate the pod, then systemctl edit --full --force pod@.service to create a new service file with the following content:

pod@.service
[Unit]
Description=Podman pod %I
After=network.target
 
[Service]
KillMode=none
RemainAfterExit=yes
ExecStartPre=/usr/bin/podman pod exists %i
ExecStart=/usr/bin/podman pod start %i
ExecStop=/usr/bin/podman pod stop -t 10 %i
 
[Install]
WantedBy=multi-user.target

Add a new pod as a service: systemctl enable pod@PODNAME.service.

timer

If you want to execute something periodically, use the service created above as Requisite for the service:

echo-xy-z.service
[Unit]
Description=Do something with the service xy inside pod z periodically.
After=pod@z.service
Requisite=pod@z.service
 
[Service]
Type=oneshot
ExecStart=podman exec -ti z_xy_1 /bin/echo 0

And create a timer based on that service:

echo-xy-z.timer
[Unit]
Description=Put a meaningful description here
 
[Timer]
# start 10min after boot, then repeat every 10min
OnBootSec=10min
OnUnitActiveSec=10min
Unit=echo-xy-z.service
 
[Install]
WantedBy=timers.target

Principles

further reading