Podman is pretty cool, and I have been playing around with it a bit recently.
Podman is essentially docker but without a daemon so it runs in userspace, and is developed by RedHat so it has nice things like Ansible integration, and is the driver behind Fedora’s Toolbox, a tool for Fedora Silverblue.
The podman blog says that you can start containers by creating an entry in /etc/systemd/system for every container that you want to start with the following example for Redis
[Unit] Description=Redis Podman container Wants=syslog.service [Service] Restart=always ExecStart=/usr/bin/podman start -a redis ExecStop=/usr/bin/podman stop -t 10 redis [Install] WantedBy=multi-user.target
However, when I looked at Wireguard’s systemd service file as an example, I found a neater way to do it.
- Create a new file
/etc/systemd/system/podman@.service(the @ is the important part – be sure not to leave that out)
- Add the following to the file:
[Unit] Description=podman %I container [Service] Restart=always ExecStart=/usr/bin/podman start -a %i ExecStop=/usr/bin/podman stop -t 2 %i [Install] WantedBy=local.target
- Stop (don’t rm) the container you want to run, and take note of its container name, eg: bitwarden_bitwarden_1
- Start and enable the service with
systemctl enable --now podman@container_name
I hope this helps someone out there 😀