Bitwarden @ Debian 12 – starting it via systemd
(Docker based installation of Bitwarden)

Recently I was setting my my own, personal, Bitwarden server. The last step, that left, was to configure systemd service in order to make sure my Bitwarden installation starts up whenever machine is rebooted.

I have spent few hours to solve this issue due to mysterious error inside /var/log/syslog:

dockerd[636]: ... level=warning msg="Error getting v2 registry: 
  Get \"\": 
  dial tcp: lookup on 
  dial udp connect: network is unreachable"

The problem was that the service was working perfectly fine when started manually. Whenever I called

> systemctl start bitwarden
> systemctl stop bitwarden

everything was working as expected. Even though it was looking fine, server startup was failing whenever system was rebooted. It turned out, this is an issue with network being not quite really alive. It seems like dependency on (this is implied by docker.service) was not enough. Eventually, my service looks like this:

Description=Bitwarden service


StartLimitInterval=100                       # I want to retry only few times. If it fails
StartLimitBurst=5                            # to start too many times, something is probably broken

Type=oneshot                                 # we are using a script that starts everything and quits
RemainAfterExit=true                         # we want to mark service live after return 0
ExecStart=/opt/bitwarden/ start
ExecStop=/opt/bitwarden/ stop
Restart=on-failure                           # these two lines makes it really work
RestartSec=10                                # it looks like dependency on docker.service is not enough


Eventually, I am able to run Bitwarden each time machine is restarted. BTW, there is another approach here: – haven’t tried this one yet, even though it looks promising.