visit
sudo apt update
sudo apt install podman
My normal setup includes the admin panel enabled and registration of new users disabled. To enable the admin panel we have to pass an ADMIN_TOKEN
environment variable. It is recommended to use a long random string for this value. We can generate it using the openssl rand
command:
openssl rand -base64 48
sudo mkdir /vw-data
sudo podman pull vaultwarden/server:latest
sudo podman run -d --name vaultwarden.pod -e ADMIN_TOKEN=YOUR_RANDOM_TOKEN_GOES_HERE -v /vw-data/:/data/ -p 8000:80 vaultwarden/server:latest
Create a service file under /etc/systemd/system/vaultwarden.pod.service
:
sudo touch /etc/systemd/system/vaultwarden.pod.service
I like to have the .pod
suffix to differentiate native services from containerized services.
[Unit]
Description=Vaultwarden/Bitwarden Server (Rust Edition)
Documentation=//github.com/dani-garcia/vaultwarden
Wants=syslog.service
[Service]
Restart=on-failure
ExecStart=/usr/bin/podman start -a vaultwarden.pod
ExecStop=/usr/bin/podman stop vaultwarden.pod
[Install]
WantedBy=multi-user.target
Restart=on-failure
is instructing to only restart the service when it exits with non-zero code. It allows us to stop the service using the podman stop
as well as the systemctl
command.podman start -a
. The -a
option instructs to attach the container’s STDOUT and STDERR.WantedBy
is needed to start our container on system boot. The multi-user.target
option basically means that the service should be started when all network services are up and the system is ready to accept logins. If you omit the WantedBy
option your service will NOT start on boot.Wants=syslog.service
option tells that syslog should be started when our service is being started. However, it’s a weak requirement and the service will still start if syslog fails to start. In other words, we would like to have logs but it’s not mandatory for our service.
sudo systemctl daemon-reload
sudo systemctl status vaultwarden.pod
● vaultwarden.pod.service - Vaultwarden/Bitwarden Server (Rust Edition)
Loaded: loaded (/etc/systemd/system/vaultwarden.pod.service; disabled; vendor preset: enabled)
Active: active (running) since Thu 2022-05-26 15:25:08 UTC; 1 day 20h ago
Docs: //github.com/dani-garcia/vaultwarden
Main PID: 19461 (podman)
Tasks: 11 (limit: 1112)
Memory: 26.9M
CGroup: /system.slice/vaultwarden.pod.service
├─19461 /usr/bin/podman start -a vaultwarden.pod
└─19574 /usr/libexec/podman/conmon --api-version 1 -c e2a6a794ddf8bb74308a9f64b98871913f6a46a8370c921dcb353f5db721cea0 -u e2a6a794ddf8bb74308a9f64b98871913f6a46a8370c921dcb353f5db721cea0 -r /usr/bin/crun -b /var/lib/containers/storage/overlay-containers/e2a6a7>
sudo systemctl stop vaultwarden.pod
sudo systemctl start vaultwarden.pod