Using Podman
NAVras-Y updated on Jul 28, 2024.
Podman is a daemonless alternative to Docker, which is mostly compatible with Docker containers.
Creating a Quadlet (Podman 4.4+)
As of version 4.4, Podman uses quadlets and will show a warning if you use the previous generate systemd method.
Additional benefit is that this method will keep the container updated.
Configuration via environment file
Configuration may be easier in an environment file and less error-prone.
NOTE: this file contains secrets, make sure only root has access!
Creating the podman quadlet
Configuration looks like systemd's but we configure a Container, not a Unit. See the documentation for all [Container] directives.
After editing the quadlet, run systemctl daemon-reload to create or updates the systemd unit. You control this container using regular systemctl commands, e.g. systemctl start vaultwarden.service.
Auto update
auto-update automates the update process.
Or, you can enable the timer which invokes auto-update daily (by default, may be edited).
Creating a systemd service file (older Podman versions)
Podman is easier to run in systemd than Docker due to its daemonless architechture. It comes with a handy generate systemd command which can generate systemd files. Here is a good article that goes into more detail as well as this article detailing some more recent updates.
You can provide a --files flag to tell podman to put the systemd service into a file or use podman generate systemd --name vaultwarden > /etc/systemd/system/container-vaultwarden.service. With this we can enable and start the container as any normal service file.
New container every restart
If we want to create a new container every time the service starts we can use the podman generate systemd --new command to generate a service file that recreates containers
If you're using an older Podman, you can edit the service file to contain the following instead:
Where vaultwarden.conf environment file can contain all the container environment values you need
If you want the container to have a specific name, you might need to add ExecStartPre=/usr/bin/podman rm -i -f vaultwarden if the process isn't cleaned up correctly. Note that this method currently doesn't work with the User= options users (see https://github.com/containers/podman/issues/5572).
Troubleshooting
Debugging systemd service file
If the host goes down or the container crashes, the systemd service file should automatically stop the existing container and spin it up again. We can find the error through journalctl -u container-vaultwarden -t 100.
Most of the time the errors we see can be fixed by simply upping the timeout in Podman command in the service file.