0
0
Fork 0
mirror of https://github.com/dani-garcia/vaultwarden synced 2024-06-08 15:08:58 +02:00

Renamed values according to the README

Proxymiity ☆ 2021-04-29 20:39:08 +02:00
parent f66ff24069
commit 9dbe013006

@ -3,9 +3,9 @@
# Creating a systemd service file
Podman is easier to run in systemd than Docker due to its daemonless architechture. It comes with a handy [generate systemd command](http://docs.podman.io/en/latest/markdown/podman-generate-systemd.1.html) which can generate systemd files. Here is a [good article that goes into more detail](https://www.redhat.com/sysadmin/podman-shareable-systemd-services) as well as [this article detailing some more recent updates](https://www.redhat.com/sysadmin/improved-systemd-podman).
```sh
$ podman run -d --name bitwarden -v /bw-data/:/data/:Z -e ROCKET_PORT=8080 -p 8080:8080 vaultwarden/server:latest
$ podman run -d --name vaultwarden -v /vw-data/:/data/:Z -e ROCKET_PORT=8080 -p 8080:8080 vaultwarden/server:latest
54502f309f3092d32b4c496ef3d099b270b2af7b5464e7cb4887bc16a4d38597
$ podman generate systemd --name bitwarden
$ podman generate systemd --name vaultwarden
# container-foo.service
# autogenerated by Podman 1.6.2
# Tue Nov 19 15:49:15 CET 2019
@ -16,8 +16,8 @@ Documentation=man:podman-generate-systemd(1)
[Service]
Restart=on-failure
ExecStart=/usr/bin/podman start bitwarden
ExecStop=/usr/bin/podman stop -t 10 bitwarden
ExecStart=/usr/bin/podman start vaultwarden
ExecStop=/usr/bin/podman stop -t 10 vaultwarden
KillMode=none
Type=forking
PIDFile=/run/user/1000/overlay-containers/54502f309f3092d32b4c496ef3d099b270b2af7b5464e7cb4887bc16a4d38597/userdata/conmon.pid
@ -28,20 +28,20 @@ WantedBy=multi-user.target default.target
You can provide a `--files` flag to dedicate a specific file to output the systemd service file to. With this we can enable and start the container as any normal service file.
```sh
$ systemctl --user enable /etc/systemd/system/container-bitwarden.service
$ systemctl --user start container-bitwarden.service
$ systemctl --user enable /etc/systemd/system/container-vaultwarden.service
$ systemctl --user start container-vaultwarden.service
```
## New container every restart
If we want to create a new container every time the service starts we can edit the service file to contain the following:
```sh
[Unit]
Description=Podman container-bitwarden.service
Description=Podman container-vaultwarden.service
[Service]
Restart=on-failure
ExecStartPre=/usr/bin/rm -f /%t/%n-pid /%t/%n-cid
ExecStart=/usr/bin/podman run --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid --env-file=/home/spytec/Bitwarden/bitwarden.conf -d -p 8080:8080 -v /home/spytec/Bitwarden/bw-data:/data/:Z vaultwarden/server:latest
ExecStart=/usr/bin/podman run --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid --env-file=/home/spytec/Vaultwarden/vaultwarden.conf -d -p 8080:8080 -v /home/spytec/Vaultwarden/vw-data:/data/:Z vaultwarden/server:latest
ExecStop=/usr/bin/podman stop -t "15" --cidfile /%t/%n-cid
ExecStop=/usr/bin/podman rm -f --cidfile /%t/%n-cid
KillMode=none
@ -51,15 +51,15 @@ PIDFile=/%t/%n-pid
[Install]
WantedBy=multi-user.target default.target
```
Where `bitwarden.conf` environment file can contain all the container environment values you need
Where `vaultwarden.conf` environment file can contain all the container environment values you need
```conf
ROCKET_PORT=8080
```
If you want the container to have a specific name, you might need to add `ExecStartPre=/usr/bin/podman rm -i -f bitwarden` 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).
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 --user -u container-bitwarden -t 100`.
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 --user -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.