---
title: How to Deploy OpenBao - An Open-Source Secrets Management Platform
url: https://docs.vultr.com/how-to-deploy-openbao-an-open-source-secrets-management-platform
description: Deploy OpenBao on a Linux server using Docker Compose with Raft storage and Traefik for HTTPS, then manage secrets with policies, userpass, the CLI, and API.
publish_date: 2026-11-26T14:57:16.309390Z
last_updated: 2026-11-26T15:13:06.499671Z
author: Zulkarnain Chauhan
header_image: https://lhr1.vultrobjects.com/docs-main-doc-assets-1/2685/6f816506-ea2e-47e2-a459-f8c28a5f8c06.png
---

> Index of every Vultr Docs page in markdown: https://docs.vultr.com/llms.txt

[OpenBao](https://openbao.org/) is an open-source secrets management platform that stores, generates, and controls access to credentials, certificates, and encryption keys. It began as a community fork of HashiCorp Vault and is governed by the Linux Foundation under the Mozilla Public License 2.0 (MPL-2.0). OpenBao exposes an HTTP API, a CLI, and a web interface that share the same authentication model, so applications and operators consume secrets through a single audited endpoint instead of storing plaintext credentials in configuration files.

This article explains how to install OpenBao with Docker Compose on a Linux-based server. It covers the server configuration for the Raft integrated storage backend, deployment behind a Traefik reverse proxy with automatic TLS certificates, initialization and unsealing, configuration of the key-value version 2 secrets engine with an access control policy and a user account, and secret storage and retrieval through the CLI and the HTTP API of the self-hosted deployment.

## Prerequisites

Before you begin, ensure you:

* Have access to a [Linux-based server](https://docs.vultr.com/products/compute/cloud-compute/provisioning) (with at least 2 CPU cores and 4 GB of RAM) as a [non-root user with sudo privileges](https://docs.vultr.com/how-to-create-a-sudo-user-in-linux).
* [Install Docker and Docker Compose](https://docs.vultr.com/how-to-install-docker-on-ubuntu-24-04).
* Create a [DNS A record](https://docs.vultr.com/products/network/dns/management/manage-records) pointing to your server's IP address (for example, `bao.example.com`).

## Set Up the Directory Structure, Configuration, and Environment Variables

OpenBao reads its runtime settings from a HashiCorp Configuration Language (HCL) file that declares the network listener, the storage backend, and the cluster addresses. The Raft integrated storage backend writes encrypted data to a local directory, which removes the need for an external database.

1. Create the project directory along with a configuration subdirectory.

    ```console
    $ mkdir -p ~/openbao/config
    ```

1. Switch to the project directory.

    ```console
    $ cd ~/openbao
    ```

1. Create the OpenBao server configuration file.

    ```console
    $ nano config/config.hcl
    ```

1. Add the following Raft storage configuration. Replace `bao.example.com` with your domain name.

    ```hcl
    ui = true

    storage "raft" {
      path    = "/openbao/file"
      node_id = "openbao-node-1"
    }

    listener "tcp" {
      address     = "0.0.0.0:8200"
      tls_disable = true
    }

    audit "file" "app-audit" {
      description = "Records every request and response to the mounted logs volume."
      options {
        file_path = "/openbao/logs/audit.log"
      }
    }

    api_addr     = "https://bao.example.com"
    cluster_addr = "https://openbao:8201"
    ```

    Save and close the file.

    The above configuration declares the following settings:

    * `ui`: Enables the built-in web interface at the `/ui` path.
    * `storage "raft"`: Selects the integrated storage backend. The `path` value matches the data directory inside the container, and `node_id` identifies the node within the Raft cluster.
    * `listener "tcp"`: Binds the API to all container interfaces on port `8200`. TLS terminates at Traefik, so the listener serves plain HTTP on the private Docker network and is never published to the host.
    * `audit "file"`: Declares a file audit device that records every request and response to the mounted logs volume. Declaring the device in the configuration file activates auditing from the first boot.
    * `api_addr`: The external URL that OpenBao advertises to clients for request redirection.
    * `cluster_addr`: The internal address used for server-to-server communication on port `8201`.

1. Create the environment file.

    ```console
    $ nano .env
    ```

1. Add the following variables. Replace `bao.example.com` with the domain that resolves to your server, and `ADMIN_EMAIL` with a deliverable address on a domain you control, because Let's Encrypt rejects addresses on reserved domains such as `example.com`.

    ```ini
    BAO_DOMAIN=bao.example.com
    ACME_EMAIL=ADMIN_EMAIL
    ```

    Save and close the file.

## Deploy with Docker Compose

The deployment runs two containers on a shared bridge network. Traefik accepts external traffic on ports `80` and `443`, requests a Let's Encrypt certificate through the TLS-ALPN challenge, and forwards decrypted requests to the OpenBao container on port `8200`. Named volumes preserve the Raft database and audit logs across container replacements.

1. Create the Compose file.

    ```console
    $ nano docker-compose.yml
    ```

1. Add the following configuration:

    ```yaml
    services:
      openbao:
        image: openbao/openbao:2.6.1
        container_name: openbao
        restart: unless-stopped
        command: server
        environment:
          BAO_ADDR: http://127.0.0.1:8200
        volumes:
          - ./config:/openbao/config:ro
          - openbao-data:/openbao/file
          - openbao-logs:/openbao/logs
        networks:
          - openbao-network
        labels:
          - "traefik.enable=true"
          - "traefik.http.routers.openbao.rule=Host(`${BAO_DOMAIN}`)"
          - "traefik.http.routers.openbao.entrypoints=websecure"
          - "traefik.http.routers.openbao.tls.certresolver=letsencrypt"
          - "traefik.http.services.openbao.loadbalancer.server.port=8200"

      traefik:
        image: traefik:v3.7.10
        container_name: traefik
        restart: unless-stopped
        command:
          - "--providers.docker=true"
          - "--providers.docker.exposedbydefault=false"
          - "--entrypoints.web.address=:80"
          - "--entrypoints.web.http.redirections.entrypoint.to=websecure"
          - "--entrypoints.web.http.redirections.entrypoint.scheme=https"
          - "--entrypoints.websecure.address=:443"
          - "--certificatesresolvers.letsencrypt.acme.email=${ACME_EMAIL}"
          - "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
          - "--certificatesresolvers.letsencrypt.acme.tlschallenge=true"
        ports:
          - "80:80"
          - "443:443"
        volumes:
          - /var/run/docker.sock:/var/run/docker.sock:ro
          - ./letsencrypt:/letsencrypt
        networks:
          - openbao-network

    volumes:
      openbao-data:
      openbao-logs:

    networks:
      openbao-network:
        driver: bridge
    ```

    Save and close the file.

    In this configuration:

    * `command`: Overrides the image default, which starts a throwaway development server, and launches a production server instead. The entrypoint loads every configuration file in `/openbao/config`.
    * `BAO_ADDR`: Points the CLI inside the container at the local listener, so administrative commands run without an address flag.
    * `./config:/openbao/config:ro`: Mounts the configuration directory read-only.
    * `openbao-data`: Stores the Raft database that holds every encrypted secret. Deleting this volume destroys the deployment data.
    * `labels`: Registers the container with Traefik, matches requests for the configured host, and enables certificate issuance through the `letsencrypt` resolver.
    * `exposedbydefault=false`: Routes only containers that explicitly set `traefik.enable=true`.

1. Start the stack in detached mode.

    ```console
    $ docker compose up -d
    ```

1. Verify that both containers are running.

    ```console
    $ docker compose ps
    ```

    The output displays two running containers with Traefik listening on ports 80 and 443.

1. Inspect the OpenBao logs to verify that the server started.

    ```console
    $ docker compose logs openbao
    ```

    The output displays a configuration summary followed by a message confirming that the server started. The log may begin with `chown: /openbao/config: Read-only file system` warnings. These warnings are expected because the configuration directory is mounted read-only, and they do not affect the server.

1. Verify that Traefik issued a certificate and routes traffic to OpenBao. Replace `bao.example.com` with your domain name.

    ```console
    $ curl -I https://bao.example.com/v1/sys/health
    ```

    The response returns an HTTP `501` status, which OpenBao uses to report an uninitialized server, and `curl` raises no certificate error. Certificate issuance takes up to a minute after the containers start. A certificate error or a connection timeout indicates that the domain does not resolve to the server or that inbound traffic on ports `80` and `443` is blocked.

## Access and Configure OpenBao

A newly deployed server is both uninitialized and sealed. Initialization generates the root encryption key, splits it into Shamir key shares, and returns the initial root token. The server decrypts its storage only after an operator supplies a threshold number of shares.

1. Initialize the server with three key shares and an unseal threshold of two.

    ```console
    $ docker compose exec openbao bao operator init -key-shares=3 -key-threshold=2
    ```

    The output resembles the following:

    ```
    Unseal Key 1: JQ3UVC11z8zCI1k0j1cg/M2TkGbTS/RYiCmxedDGNu/E
    Unseal Key 2: Bv9HCpu1Fv44cWY1/i9YCQvXODnC+N53g2XPG/1tL5tf
    Unseal Key 3: 2F4cilGWdHyEbxxTPpTjgWe8mt+e13s3NBM7S3Flbr4Z

    Initial Root Token: s.B1xwAeU4gFHAhSIjGF7C3xZS

    Vault initialized with 3 key shares and a key threshold of 2. Please securely
    distribute the key shares printed above. When the Vault is re-sealed,
    restarted, or stopped, you must supply at least 2 of these keys to unseal it
    before it can start servicing requests.
    ...
    ```

    OpenBao inherits several user-facing strings from its Vault origin, so the message refers to Vault.

    > [!WARNING]
    > * Store the unseal keys and the root token in separate secure locations outside the server. OpenBao does not store them, and losing a threshold number of shares permanently locks the encrypted data.
    > * Distribute individual key shares to different operators so that no single person can unseal the server alone.

1. Supply the first unseal key. Replace `UNSEAL_KEY_1` with the first key from the initialization output.

    ```console
    $ docker compose exec openbao bao operator unseal UNSEAL_KEY_1
    ```

    The output reports `Sealed` as `true` and an unseal progress of `1/2`.

1. Supply the second unseal key. Replace `UNSEAL_KEY_2` with the second key.

    ```console
    $ docker compose exec openbao bao operator unseal UNSEAL_KEY_2
    ```

    The output reports `Sealed` as `false`, which confirms that the server is ready to serve requests. The `HA Mode` field reads `standby` for a few seconds while the node completes leader election, then reads `active`.

    The server starts sealed after every container restart. Production deployments avoid this manual unseal with an auto-unseal seal stanza backed by a cloud Key Management Service (KMS) or a second OpenBao instance running the Transit engine.

1. Authenticate with the initial root token. Replace `ROOT_TOKEN` with the token from the initialization output.

    ```console
    $ docker compose exec openbao bao login ROOT_TOKEN
    ```

    The output confirms that the token is stored and lists its attached policies, `root` among them.

1. Enable the key-value version 2 secrets engine at the `kv` path.

    ```console
    $ docker compose exec openbao bao secrets enable -path=kv kv-v2
    ```

    The output confirms that the engine is enabled at `kv/`. Version 2 retains a configurable history of every secret, which allows rollbacks and soft deletion.

1. Verify that the audit device declared in the configuration file is active.

    ```console
    $ docker compose exec openbao bao audit list
    ```

    The output lists the `app-audit/` device with type `file`. OpenBao writes one structured JSON entry per request and response, with sensitive values replaced by HMAC digests.

1. Create an access control policy file in the project directory.

    ```console
    $ nano app-policy.hcl
    ```

1. Add the following policy:

    ```hcl
    path "kv/data/app/*" {
      capabilities = ["create", "read", "update", "delete", "list"]
    }

    path "kv/metadata/app/*" {
      capabilities = ["read", "list", "delete"]
    }
    ```

    Save and close the file.

    The policy grants access only to secrets under the `app/` prefix. The `kv/data/` path controls the secret values, while `kv/metadata/` controls version history and deletion metadata. OpenBao denies every path that a policy does not explicitly allow.

1. Write the policy to the server.

    ```console
    $ docker compose exec -T openbao bao policy write app-policy - < app-policy.hcl
    ```

    The `-` argument reads the policy from standard input, which keeps the file out of the mounted configuration directory. The output confirms that OpenBao uploaded the `app-policy` policy.

1. Enable the userpass authentication method.

    ```console
    $ docker compose exec openbao bao auth enable userpass
    ```

    The output confirms `Success! Enabled userpass auth method at: userpass/`. Accounts under this method authenticate with a username and password and receive a token scoped to the attached policies.

1. Create a user account bound to the policy. Replace `STRONG_PASSWORD` with a strong password.

    ```console
    $ docker compose exec openbao bao write auth/userpass/users/appuser \
        password=STRONG_PASSWORD \
        token_policies=app-policy
    ```

    Tokens issued to this account inherit `app-policy` and cannot read secrets outside the `app/` prefix. Each token expires after the default lease duration of 768 hours.

1. Open `https://bao.example.com` in a web browser, replacing `bao.example.com` with your domain name. Select **Username** as the authentication method, then enter `appuser` and the password to sign in.

    The interface displays the secrets engines that the token can access.

## Manage Secrets Through the CLI and API

A complete secret lifecycle spans an operator write through the CLI and an application read over the HTTPS API with a token scoped to the `appuser` account.

### Store a Secret via CLI

The `bao kv` command group writes and reads structured secrets. Each write creates a new version rather than overwriting the previous value.

1. Write a database credential to the `app/database` path. Replace `DB_PASSWORD` with the actual database password.

    ```console
    $ docker compose exec openbao bao kv put kv/app/database \
        username=app_admin \
        password=DB_PASSWORD
    ```

    The output confirms the write and reports `version 1`.

1. Read the secret back.

    ```console
    $ docker compose exec openbao bao kv get kv/app/database
    ```

    The output resembles the following:

    ```
    ==== Secret Path ====
    kv/data/app/database

    ======= Metadata =======
    Key                Value
    ---                -----
    created_time       2026-08-09T19:51:37.543247332Z
    custom_metadata    <nil>
    deletion_time      n/a
    destroyed          false
    version            1

    ====== Data ======
    Key         Value
    ---         -----
    password    ...
    username    app_admin
    ```

1. Update the password to create a second version. Replace `NEW_DB_PASSWORD` with the rotated password.

    ```console
    $ docker compose exec openbao bao kv put kv/app/database \
        username=app_admin \
        password=NEW_DB_PASSWORD
    ```

    The output reports `version 2`, and clients that read the secret without a version parameter now receive the updated value.

1. Retrieve the earlier version to verify that the history is intact.

    ```console
    $ docker compose exec openbao bao kv get -version=1 kv/app/database
    ```

    The output displays the original password along with `version 1` in the metadata.

### Retrieve the Secret via API

The HTTP API exposes the same operations through Traefik over HTTPS. A client exchanges its credentials for a short-lived client token, then sends that token in the `X-Vault-Token` header, a name OpenBao retains for compatibility with existing Vault client libraries.

1. Authenticate as `appuser` to request a client token. Replace `STRONG_PASSWORD` with the account password, and `bao.example.com` with your domain name.

    ```console
    $ curl --request POST \
        --data '{"password": "STRONG_PASSWORD"}' \
        https://bao.example.com/v1/auth/userpass/login/appuser
    ```

    The response contains an `auth` object with a `client_token` field, a `policies` array listing `app-policy` and `default`, and a `lease_duration` of `2764800` seconds.

1. Export the returned token as a shell variable. Replace `CLIENT_TOKEN` with the `client_token` value from the previous response.

    ```console
    $ export BAO_TOKEN=CLIENT_TOKEN
    ```

1. Read the database credential through the API. Replace `bao.example.com` with your domain name.

    ```console
    $ curl --header "X-Vault-Token: $BAO_TOKEN" \
        https://bao.example.com/v1/kv/data/app/database
    ```

    The response nests the secret under `data.data` and the version details under `data.metadata`, which reflects the two-layer structure of the version 2 engine.

1. Write a new secret through the API. Replace `YOUR_APP_API_KEY` with the key your application uses, and `bao.example.com` with your domain name.

    ```console
    $ curl --request POST \
        --header "X-Vault-Token: $BAO_TOKEN" \
        --data '{"data": {"api_key": "YOUR_APP_API_KEY"}}' \
        https://bao.example.com/v1/kv/data/app/service
    ```

    The response returns the created version number and its metadata.

1. Verify that a request outside the permitted prefix fails. Replace `bao.example.com` with your domain name.

    ```console
    $ curl --header "X-Vault-Token: $BAO_TOKEN" \
        https://bao.example.com/v1/kv/data/internal/root
    ```

    The response returns an HTTP `403` status with the body `{"errors":["1 error occurred:\n\t* permission denied\n\n"]}`, which confirms that `app-policy` restricts the token to the `app/` prefix.

## Conclusion

You have deployed OpenBao on a Linux-based server with Docker Compose, secured the endpoint with automatic TLS certificates through Traefik, initialized and unsealed the server backed by Raft integrated storage, and configured the key-value secrets engine with a least-privilege policy and a dedicated user account. Applications now read credentials through the CLI or the HTTP API with scoped tokens, and the file audit device records every request. To extend the deployment, enable additional secrets engines such as PKI for certificate issuance, Transit for encryption as a service, or the database engine for dynamic, short-lived credentials. For more information, visit the [official OpenBao documentation](https://openbao.org/docs/).