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 $.
1. Write the Compose file
Section titled “1. Write the Compose file”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:dataholds 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
DOMAINtells Vaultwarden the address it is reached at. WebSocket notifications use the same port, so the proxy needs nothing special for them.
2. Write its variables
Section titled “2. Write its variables”VAULTWARDEN_TAG=1.37.5DOMAIN=https://vault.example.netSIGNUPS_ALLOWED=trueSIGNUPS_ALLOWED is true only until your own account exists. The admin token
is set separately, in step 4.
3. Deploy it and create your account
Section titled “3. Deploy it and create your account”kaio-cli stack deploy vaultwarden ./compose.yml --env-file .envkaio-cli stack logs vaultwarden --followOpen the domain, create your account, then close the door behind you:
kaio-cli stack env set vaultwarden SIGNUPS_ALLOWED=falsekaio-cli stack apply vaultwarden4. Set the admin token as a hash
Section titled “4. Set the admin token as a hash”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:
kaio-cli container shell <vaultwarden-container>/vaultwarden hashIt 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:
kaio-cli stack env set vaultwarden 'ADMIN_TOKEN=$argon2id$v=19$m=65540,t=3,p=4$...' --secretkaio-cli stack apply vaultwardenVaultwarden’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.
5. Back it up, then update
Section titled “5. Back it up, then update”The data volume is the vaults. Before anything that touches it, copy it,
paused so SQLite is not written to mid-copy:
kaio-cli stack pause vaultwardenkaio-cli stack copy vaultwarden --as vaultwarden-backup --with-volumes --port-offset 1000kaio-cli stack unpause vaultwardenA 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.
kaio-cli stack check-update vaultwardenkaio-cli stack env set vaultwarden VAULTWARDEN_TAG=<next-release>kaio-cli stack apply vaultwardenkaio-cli stack scan vaultwardenA rollback brings back the previous image and variables, but not a database the newer version migrated: the copy above is what makes that recoverable.
Moving it
Section titled “Moving it”kaio-cli stack copy vaultwarden --to prod-02 --with-volumesThe 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