Skip to content
Kaiov0.8.0

Vaultwarden

Vaultwarden is a lightweight server for the Bitwarden apps and browser extensions. Of all the stacks on a host it is the one whose data matters most, and the one whose configuration has a trap: an admin token that is full of $.

services:
vaultwarden:
image: docker.io/vaultwarden/server:${VAULTWARDEN_TAG:-latest}
restart: unless-stopped
environment:
- DOMAIN=${DOMAIN}
- SIGNUPS_ALLOWED=${SIGNUPS_ALLOWED:-false}
- ADMIN_TOKEN=${ADMIN_TOKEN}
ports:
- "127.0.0.1:11001:80"
volumes:
- data:/data
volumes:
data:
  • data holds everything: the SQLite database with every vault, the attachments, the icons cache and, once the admin page has saved anything, config.json.
  • The port stays on the loopback. The web vault and the apps need HTTPS, so a reverse proxy terminates TLS in front and DOMAIN tells Vaultwarden the address it is reached at. WebSocket notifications use the same port, so the proxy needs nothing special for them.
VAULTWARDEN_TAG=1.37.5
DOMAIN=https://vault.example.net
SIGNUPS_ALLOWED=true

SIGNUPS_ALLOWED is true only until your own account exists. The admin token is set separately, in step 4.

Terminal window
kaio-cli stack deploy vaultwarden ./compose.yml --env-file .env
kaio-cli stack logs vaultwarden --follow

Open the domain, create your account, then close the door behind you:

Terminal window
kaio-cli stack env set vaultwarden SIGNUPS_ALLOWED=false
kaio-cli stack apply vaultwarden

The /admin page is off while ADMIN_TOKEN is empty. Vaultwarden accepts the token in clear, but warns about it; the better form is an Argon2 hash, which the image generates itself:

Terminal window
kaio-cli container shell <vaultwarden-container>
/vaultwarden hash

It asks for a password twice and prints a string like $argon2id$v=19$m=65540,t=3,p=4$.... Store it in Kaio, single-quoted so the shell keeps the $ as they are:

Terminal window
kaio-cli stack env set vaultwarden 'ADMIN_TOKEN=$argon2id$v=19$m=65540,t=3,p=4$...' --secret
kaio-cli stack apply vaultwarden

Vaultwarden’s documentation tells you to double every $ when the hash goes in a Compose file, because Compose would read $argon2id as a variable. Through Kaio there is nothing to double: Kaio writes each value to the stack’s .env single-quoted, which Compose takes literally, and ${ADMIN_TOKEN} in the Compose file receives the hash untouched. The name ends in _TOKEN, so it is flagged as a secret and masked everywhere. /admin now takes the password you typed, not the hash.

The data volume is the vaults. Before anything that touches it, copy it, paused so SQLite is not written to mid-copy:

Terminal window
kaio-cli stack pause vaultwarden
kaio-cli stack copy vaultwarden --as vaultwarden-backup --with-volumes --port-offset 1000
kaio-cli stack unpause vaultwarden

A clone on the same host would claim 127.0.0.1:11001, which the paused source still holds, so Kaio refuses it unless its port moves: --port-offset publishes it on 12001 instead. The copy lands stopped, under another name, with its own volume: a snapshot of the vaults you can start if an upgrade goes wrong. See Backup for Kaio’s own database, which holds the admin token.

Terminal window
kaio-cli stack check-update vaultwarden
kaio-cli stack env set vaultwarden VAULTWARDEN_TAG=<next-release>
kaio-cli stack apply vaultwarden
kaio-cli stack scan vaultwarden

A rollback brings back the previous image and variables, but not a database the newer version migrated: the copy above is what makes that recoverable.

Terminal window
kaio-cli stack copy vaultwarden --to prod-02 --with-volumes

The vaults move with the volume, and the clients keep working as long as DOMAIN points at the new server: change the DNS record, not the apps.

Kaio, built by Régis Gaidot