Generate a systemd unit file using Podman
Create systemd unit files for existing containers by using the podman generate systemd command. This allows Podman to manage running containers as services, though Quadlets are preferred for new configurations.
Before you begin
- The
container-toolsmeta-package is installed.
About this task
The podman generate systemd command also helps ensure that you get the latest version of unit files.
systemd unit files and hides the complexity of running containers under systemd.Procedure
Results
- Display the content of generated
systemdunit file:$ cat ~/.config/systemd/user/container-myubi.service# container-myubi.service # autogenerated by Podman 3.3.1 # Wed Sep 8 20:34:46 CEST 2021 [Unit] Description=Podman container-myubi.service Documentation=man:podman-generate-systemd(1) Wants=network-online.target After=network-online.target RequiresMountsFor=/run/user/1000/containers [Service] Environment=PODMAN_SYSTEMD_UNIT=%n Restart=on-failure TimeoutStopSec=70 ExecStart=/usr/bin/podman start myubi ExecStop=/usr/bin/podman stop -t 10 myubi ExecStopPost=/usr/bin/podman stop -t 10 myubi PIDFile=/run/user/1000/containers/overlay-containers/9683103f58a32192c84801f0be93446cb33c1ee7d9cdda225b78049d7c5deea4/userdata/conmon.pid Type=forking [Install] WantedBy=multi-user.target default.target- The
Restart=on-failureline sets the restart policy and instructssystemdto restart when the service cannot be started or stopped cleanly, or when the process exits non-zero. - The
ExecStartline describes how we start the container. - The
ExecStopline describes how we stop and remove the container.For more information, see
podman-generate-systemd(1)man page on your system.
- The