Self-Host Vaultwarden with Docker and HTTPS (Compose File Included)

Two containers and one folder give you a working password vault. Vaultwarden keeps everything in vw-data, Caddy puts https in front of it, and once your account exists you switch sign-ups off and hash the admin token.

Vaultwarden is a small, unofficial server that speaks Bitwarden's language, so Bitwarden's own apps and browser extension work with it. You run it in Docker. Two containers do the job: Vaultwarden itself, and Caddy in front of it for https. Everything your vault holds lives in one folder, vw-data.

This is the setup from the video, taken from Vaultwarden's own wiki (Using Docker Compose). The video was filmed on a test server that only answers one computer; on a real server the steps are the same, except Caddy gets a real certificate.

What do I need before I start?

  • A Linux server with Docker and Docker Compose.
  • A domain name (for example vault.example.com) pointing at that server.
  • Ports 80 and 443 open to the internet, so Caddy can get a certificate from Let's Encrypt.

Why does Vaultwarden need https?

The web vault encrypts your passwords inside your browser, before anything is sent. Browsers only allow that on a secure (https) page, so on plain http the vault will not work from your other devices. A reverse proxy such as Caddy handles the https for Vaultwarden and renews the certificate on its own.

What goes in the compose file?

Make a folder, and save this as compose.yaml. Change both domain lines and the email.

services:
  vaultwarden:
    image: vaultwarden/server:latest
    container_name: vaultwarden
    restart: always
    environment:
      DOMAIN: "https://vault.example.com"
      SIGNUPS_ALLOWED: "true"   # set to "false" once your account exists
    volumes:
      - ./vw-data:/data

  caddy:
    image: caddy:2
    container_name: caddy
    restart: always
    ports:
      - 80:80
      - 443:443
      - 443:443/udp
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - ./caddy-config:/config
      - ./caddy-data:/data
    environment:
      DOMAIN: "https://vault.example.com"
      EMAIL: "you@example.com"

In the same folder, save this as Caddyfile:

{$DOMAIN} {
  tls {$EMAIL}
  encode zstd gzip
  reverse_proxy vaultwarden:80 {
    header_up X-Real-IP {remote_host}
  }
}

Start both containers with docker compose up -d. The wiki pins nothing (latest); if you'd rather choose when to upgrade, put a version number in the image line, such as vaultwarden/server:1.37.5, the version the video used.

How do I make the first account?

  1. Open your domain in a browser and choose Create account.
  2. Type your email and name, then choose a master password. It cannot be recovered: if you lose it, nobody can open the vault, not even the server's admin. A long phrase you will remember works well.
  3. Leave "Check known data breaches for this password" ticked. It sends only a small piece of a scrambled copy of the password.

To use the vault on your phone, open the Bitwarden app, and before you log in change "Logging in on" to self-hosted and type your address. The browser extension works the same way.

How do I stop strangers signing up?

Until you change it, anyone who finds your address can make an account on your server. Two ways to close it:

  • In the compose file: set SIGNUPS_ALLOWED: "false" and run docker compose up -d again.
  • On the admin page: /admin → General settings → untick Allow new signups → Save. What you save on the admin page overrides the compose file.

You can still invite people yourself from the admin page.

How do I turn on the admin page safely?

The admin page needs a token. Don't store it as plain text: hash it with Vaultwarden's own command, type your token twice, and copy the line it prints (it starts with $argon2id$).

docker exec -it vaultwarden /vaultwarden hash

Add it to the vaultwarden service's environment as ADMIN_TOKEN. In a compose file every $ must be doubled to $$, or Compose treats it as a variable. Then run docker compose up -d again and sign in at /admin with the token you typed (not the hash). To switch the admin page off, leave ADMIN_TOKEN out.

What should I back up?

The vw-data folder is the whole vault: the database, the keys and any attachments. Copy it somewhere safe, and test that the copy restores: back up Vaultwarden and test the restore has the script and the restore steps.


Related reading