Home > Software > How to Deploy Bitwarden with Docker Compose: A Secure Self-Hosted Password Manager

How to Deploy Bitwarden with Docker Compose: A Secure Self-Hosted Password Manager

Anastasios Antoniadis

Discover how to deploy Bitwarden, the open-source password manager, using Docker Compose with our step-by-step guide. Securely store and manage your passwords with ease, enhancing your digital security.

Docker (1)

Bitwarden is a popular open-source password management solution that allows individuals and organizations to store, share, and manage their passwords securely. While Bitwarden offers cloud-based services, some users may prefer to self-host their Bitwarden instance for enhanced control and privacy. Docker Compose facilitates the deployment of Bitwarden on your server, making it easier to manage containers, volumes, and configurations. This guide will walk you through deploying Bitwarden using Docker Compose.

Prerequisites

Before starting, ensure you have the following:

  • Docker installed on your server.
  • Docker Compose installed on your server.
  • A domain name pointing to your server (optional but recommended for SSL/TLS setup).

Step 1: Create a Docker Compose File

Create a new directory for your Bitwarden deployment. This directory will contain your Docker Compose file (docker-compose.yml) and any additional configuration files or directories you might need.

mkdir bitwarden-docker && cd bitwarden-docker

Create the docker-compose.yml file:

touch docker-compose.yml

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

version: '3'

services:
  bitwarden:
    image: bitwardenrs/server:latest
    container_name: bitwarden
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./bw-data:/data
    environment:
      WEBSOCKET_ENABLED: 'true' # Enable WebSocket for real-time sync
      SIGNUPS_ALLOWED: 'false'  # Optionally disable new signups
      DOMAIN: 'https://your-domain.com' # Change to your domain
    restart: always

Configuration Explained:

  • image: Uses the bitwardenrs/server:latest image, an unofficial Bitwarden-compatible server written in Rust, known for its lightweight and resource-efficient characteristics.
  • container_name: Sets a custom name for the container.
  • ports: Exposes ports 80 and 443 for HTTP and HTTPS traffic.
  • volumes: Maps a volume for persistent storage of Bitwarden data.
  • environment: Configures environment variables for WebSocket support, signup permissions, and the domain name for your Bitwarden instance.
  • restart: Ensures the container restarts automatically unless explicitly stopped.

Step 2: Launch Bitwarden

With your docker-compose.yml file ready, start Bitwarden by running:

docker compose up -d

This command pulls the necessary Docker image and starts the Bitwarden container in detached mode.

Step 3: Access Bitwarden

After a few moments, Bitwarden will be up and running. Access the Bitwarden web interface by navigating to http://localhost or https://your-domain.com if you’ve configured a domain and SSL/TLS.

When you first access Bitwarden, you’ll be prompted to create an account. Follow the on-screen instructions to set up your admin account.

Step 4: Configure SSL/TLS (Optional)

Securing your Bitwarden instance with SSL/TLS is crucial for production deployments. You can achieve this by integrating a reverse proxy like Nginx or Traefik in front of Bitwarden and using Let’s Encrypt for certificate management. Ensure that you update the DOMAIN environment variable in your Docker Compose file to reflect your secured domain.

Conclusion

Deploying Bitwarden with Docker Compose offers a straightforward method for setting up a self-hosted password management solution. Following the steps outlined in this guide, you can quickly get a Bitwarden instance running on your server, ready to store and manage your passwords securely. Docker Compose simplifies the management of the Bitwarden service, making it easy to maintain and update your instance as needed. Whether for personal use or within an organization, a self-hosted Bitwarden server provides enhanced control and privacy for sensitive data.

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