Home > Software > How to Deploy Vaultwarden with Docker Compose: An Easy Guide

How to Deploy Vaultwarden with Docker Compose: An Easy Guide

Anastasios Antoniadis

Learn how to deploy Vaultwarden, the lightweight, Bitwarden-compatible password management server, using Docker Compose.

Docker (1)

Vaultwarden is an open-source alternative to the Bitwarden server API, designed to help you store and manage your passwords securely. It’s lightweight, doesn’t require a powerful server, and is compatible with Bitwarden clients, making it an excellent choice for self-hosting. Deploying Vaultwarden using Docker Compose simplifies the setup process and makes managing your instance easier. This guide will walk you through setting up Vaultwarden using Docker Compose.

Prerequisites

Before you begin, ensure you have the following:

  • Docker installed on your host machine.
  • Docker Compose installed on your host machine.
  • Basic familiarity with Docker and Docker Compose.

Step 1: Create a Docker Compose File

First, create a directory dedicated to your Vaultwarden deployment. This directory will contain your Docker Compose file (docker-compose.yml) along with any additional configuration files or directories you may need.

mkdir vaultwarden-docker && cd vaultwarden-docker

Next, create your docker-compose.yml file:

touch docker-compose.yml

Open this file in a text editor and add the following configuration:

version: '3.1'

services:
  vaultwarden:
    image: vaultwarden/server:latest
    container_name: vaultwarden
    restart: always
    ports:
      - 80:80
    volumes:
      - ./vw-data:/data
    environment:
      - WEBSOCKET_ENABLED=true  # Optional: enables WebSocket notifications.

volumes:
  vw-data:

This Docker Compose configuration does the following:

  • vaultwarden: Defines the service using the official vaultwarden/server image.
  • container_name: Sets a custom name for easier reference.
  • restart: Ensures the container restarts automatically unless it has been explicitly stopped.
  • ports: Maps port 80 on the host to port 80 in the container, making Vaultwarden accessible via the host’s IP address or domain name.
  • volumes: Mounts a volume (./vw-data) to /data inside the container for persistent storage of Vaultwarden data.
  • environment: Sets environment variables, such as enabling WebSocket notifications, allowing real-time updates in the Bitwarden clients.

Step 2: Start Vaultwarden

With your docker-compose.yml file in place, you can start Vaultwarden by running the following command in the directory containing your Docker Compose file:

docker compose up -d

The -d flag runs the container in detached mode, allowing it to operate in the background.

Step 3: Access Vaultwarden

After a few moments, Vaultwarden will start, and you can access it by navigating to http://localhost or http://your-server-ip in your web browser. You’ll be greeted by the Vaultwarden login page, where you can create an account or log in if you already have one.

Step 4: Secure Vaultwarden (Optional)

For production use, securing your Vaultwarden instance with SSL/TLS encryption is highly recommended. You can achieve this using a reverse proxy like Nginx or Traefik with Let’s Encrypt for SSL certificates. Consider setting up a firewall and regularly updating your Docker images to keep your Vaultwarden instance secure.

Conclusion

Deploying Vaultwarden with Docker Compose offers a straightforward and efficient method to set up a self-hosted password management solution. Following the steps outlined in this guide, you can have a Vaultwarden server running on your machine, ready to store and manage your passwords securely. Docker Compose simplifies managing the Vaultwarden service, making it an ideal choice for both personal and small-scale enterprise use.

Anastasios Antoniadis
Follow me
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x