podman ❤️ systemd

Use systemd to start podman containers.

Container information:

Double check the name of the container using the podman ps command.  Use the container name as the unit filename and as the commands for ExecStart & ExecStop  in the unit file.

CONTAINER ID   IMAGE                            COMMAND                  CREATED          STATUS             PORTS                    NAMES
411a6c6be7d8   docker.io/library/test-server:latest   docker-entrypoint.s...   40 minutes ago   Up 30 minutes ago   0.0.0.0:6379->6379/tcp   <name>

Make systemd unit file:

/etc/systemd/system/<name>.service
[Unit]
Description=Podman container description here
Wants=syslog.service
[Service]
Restart=always
ExecStart=/usr/bin/podman start -a <name>
ExecStop=/usr/bin/podman stop -t 10 <name>
[Install]
WantedBy=multi-user.target

Enable service:

sudo systemctl enable <name>.service
sudo systemctl start <name>.service

See Also: https://podman.io/blogs/2018/09/13/systemd.html

Subscribe to Independent Computing

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe