Problem with Docker + bind mounted data volume: Can't connect to database, retrying: Failed to create pool

Hello there,

I’m running Vaultwarden

  • Vaultwarden version: v1.25.0
  • Web-vault version: v2.28.1
  • Running within Docker: true (Base: Debian)
  • Environment settings overridden: false
  • Uses a reverse proxy: true
  • IP Header check: true (X-Real-IP)
  • Internet access: true
  • Internet access via a proxy: false
  • DNS Check: true
  • Time Check: true
  • Domain Configuration Check: true
  • HTTPS Check: true
  • Database type: SQLite
  • Database version: 3.35.4

with this compose file

docker-compose.yml
version: '3.7'

services:
  bitwarden:
    image: vaultwarden/server:latest
    container_name: vaultwarden
    restart: always
    security_opt:
      - no-new-privileges:true
    networks:
      - proxy
    volumes:
      - ./bw-data-nas:/data
    env_file:
      .bw.env

    labels:
      traefik.enable: true

      # bitwarden-ui
      traefik.http.routers.bitwarden-ui.rule: Host(`example.org`)
      traefik.http.routers.bitwarden-ui.entrypoints: websecure
      traefik.http.routers.bitwarden-ui.tls.certresolver: tlsleresolver
      traefik.http.routers.bitwarden-ui.service: bitwarden-ui
      traefik.http.services.bitwarden-ui.loadbalancer.server.port: 80

      # bitwarden-ui bitwarden-websocket
      traefik.http.routers.bitwarden-websocket.rule: Host(`example.org`) && Path(`/notifications/hub`)
      traefik.http.routers.bitwarden-websocket.entrypoints: websecure
      traefik.http.routers.bitwarden-websocket.tls.certresolver: tlsleresolver
      traefik.http.routers.bitwarden-websocket.service: bitwarden-websocket
      traefik.http.services.bitwarden-websocket.loadbalancer.server.port: 3012

networks:
  proxy:
    external: true

In particular, the directory bw-data-nas is bind mounted (via cifs in /etc/fstab) to a Synology NAS. Everything works fine on the first run. However, when the machine running Vaultwarden is rebooted, the container goes up but it can’t connect to the database in the data volume anymore, and I get this error:

Can’t connect to database, retrying: Failed to create pool.

Sometimes, things get fixed independently after ~10 minutes.

Here is the full log of a system reboot:

log of the problem
vaultwarden  | [2022-06-30 10:43:41.893][vaultwarden][INFO] Exiting vaultwarden!
vaultwarden  | [2022-06-30 10:43:41.898][rocket::server][WARN] Received SIGTERM. Requesting shutdown.
vaultwarden  | [2022-06-30 10:43:41.898][vaultwarden][INFO] Vaultwarden process exited!
vaultwarden  | /--------------------------------------------------------------------\
vaultwarden  | |                        Starting Vaultwarden                        |
vaultwarden  | |                           Version 1.25.0                           |
vaultwarden  | |--------------------------------------------------------------------|
vaultwarden  | | This is an *unofficial* Bitwarden implementation, DO NOT use the   |
vaultwarden  | | official channels to report bugs/features, regardless of client.   |
vaultwarden  | | Send usage/configuration questions or feature requests to:         |
vaultwarden  | |   https://vaultwarden.discourse.group/                             |
vaultwarden  | | Report suspected bugs/issues in the software itself at:            |
vaultwarden  | |   https://github.com/dani-garcia/vaultwarden/issues/new            |
vaultwarden  | \--------------------------------------------------------------------/
vaultwarden  |
vaultwarden  | [INFO] No .env file found.
vaultwarden  |
vaultwarden  | [2022-06-30 10:45:21.345][vaultwarden::util][WARN] Can't connect to database, retrying: Failed to create pool.
vaultwarden  | [CAUSE] Error(
vaultwarden  |     None,
vaultwarden  | )
vaultwarden  | [2022-06-30 10:45:52.601][vaultwarden::util][WARN] Can't connect to database, retrying: Failed to create pool.
vaultwarden  | [CAUSE] Error(
vaultwarden  |     None,
vaultwarden  | )
vaultwarden  | [2022-06-30 10:46:23.800][vaultwarden::util][WARN] Can't connect to database, retrying: Failed to create pool.
vaultwarden  | [CAUSE] Error(
vaultwarden  |     None,
vaultwarden  | )
vaultwarden  | [2022-06-30 10:46:54.989][vaultwarden::util][WARN] Can't connect to database, retrying: Failed to create pool.
vaultwarden  | [CAUSE] Error(
vaultwarden  |     None,
vaultwarden  | )
vaultwarden  | [2022-06-30 10:47:26.186][vaultwarden::util][WARN] Can't connect to database, retrying: Failed to create pool.
vaultwarden  | [CAUSE] Error(
vaultwarden  |     None,
vaultwarden  | )
vaultwarden  | [2022-06-30 10:47:57.436][vaultwarden::util][WARN] Can't connect to database, retrying: Failed to create pool.
vaultwarden  | [CAUSE] Error(
vaultwarden  |     None,
vaultwarden  | )
vaultwarden  | [2022-06-30 10:48:28.639][vaultwarden::util][WARN] Can't connect to database, retrying: Failed to create pool.
vaultwarden  | [CAUSE] Error(
vaultwarden  |     None,
vaultwarden  | )
vaultwarden  | [2022-06-30 10:48:59.829][vaultwarden::util][WARN] Can't connect to database, retrying: Failed to create pool.
vaultwarden  | [CAUSE] Error(
vaultwarden  |     None,
vaultwarden  | )
vaultwarden  | [2022-06-30 10:49:31.032][vaultwarden::util][WARN] Can't connect to database, retrying: Failed to create pool.
vaultwarden  | [CAUSE] Error(
vaultwarden  |     None,
vaultwarden  | )
vaultwarden  | [2022-06-30 10:50:02.259][vaultwarden::util][WARN] Can't connect to database, retrying: Failed to create pool.
vaultwarden  | [CAUSE] Error(
vaultwarden  |     None,
vaultwarden  | )
vaultwarden  | [2022-06-30 10:50:33.502][vaultwarden::util][WARN] Can't connect to database, retrying: Failed to create pool.
vaultwarden  | [CAUSE] Error(
vaultwarden  |     None,
vaultwarden  | )
vaultwarden  | [2022-06-30 10:51:04.699][vaultwarden::util][WARN] Can't connect to database, retrying: Failed to create pool.
vaultwarden  | [CAUSE] Error(
vaultwarden  |     None,
vaultwarden  | )
vaultwarden  | [2022-06-30 10:51:35.875][vaultwarden::util][WARN] Can't connect to database, retrying: Failed to create pool.
vaultwarden  | [CAUSE] Error(
vaultwarden  |     None,
vaultwarden  | )
vaultwarden  | [2022-06-30 10:52:07.060][vaultwarden::util][WARN] Can't connect to database, retrying: Failed to create pool.
vaultwarden  | [CAUSE] Error(
vaultwarden  |     None,
vaultwarden  | )
vaultwarden  | [2022-06-30 10:52:38.247][vaultwarden][ERROR] Error creating database pool: Failed to create pool.
vaultwarden  | [CAUSE] Error(
vaultwarden  |     None,
vaultwarden  | )
vaultwarden  | /--------------------------------------------------------------------\
vaultwarden  | |                        Starting Vaultwarden                        |
vaultwarden  | |                           Version 1.25.0                           |
vaultwarden  | |--------------------------------------------------------------------|
vaultwarden  | | This is an *unofficial* Bitwarden implementation, DO NOT use the   |
vaultwarden  | | official channels to report bugs/features, regardless of client.   |
vaultwarden  | | Send usage/configuration questions or feature requests to:         |
vaultwarden  | |   https://vaultwarden.discourse.group/                             |
vaultwarden  | | Report suspected bugs/issues in the software itself at:            |
vaultwarden  | |   https://github.com/dani-garcia/vaultwarden/issues/new            |
vaultwarden  | \--------------------------------------------------------------------/
vaultwarden  |
vaultwarden  | [INFO] No .env file found.
vaultwarden  |
vaultwarden  | [2022-06-30 10:52:40.036][start][INFO] Rocket has launched from http://0.0.0.0:80

How can I fix it?

Sounds like the CIFS share is not available after the reboot atleast for awhile and thus no connection to the database can be established. If you change the location of the sqlite database to a local folder or if you switch to another database backend (e.g. MariaDB) the problem should vanish, otherwise you might also be able to delay the starting of the container (or Docker) until after the share is available.

Hi @stefan0xC! Thanx for your help. I’m sorry for this late reply. My db is on a NAS under a safe backup policy. It looks strange. Theoretically speaking, the mount should be immediately available upon system boot. Going over the log, the “Rocket has launched” message is sent after 7+ minutes. In that while, I’m pretty sure that the folder was available. What do you think about?