Database volume not mounting #4499

Closed
opened 2026-02-05 09:01:10 +03:00 by OVERLORD · 5 comments
Owner

Originally created by @need4swede on GitHub (Mar 6, 2024).

Attempted Debugging

  • I have read the debugging page

Searched GitHub Issues

  • I have searched GitHub for the issue.

Describe the Scenario

Windows 11, setup via Docker-Compose.
I am not a Docker expert by any means, but for some reason my database volume isn't being binded to my host, but the app config manages to do so just fine.

I had some issues getting it all working with MariaDB at first, but I was able to get it working by switching to MySQL instead. But for some reason, the database volume ends up in the container, rather than on my host PC. I've tried removing everything and doing a fresh install of BookStackApp, but the problem persists. Is this a bug, or am I slipping up somewhere? Thank you!

version: "2"
services:
  bookstack:
    image: lscr.io/linuxserver/bookstack
    container_name: bookstack
    environment:
      - PUID=1000
      - PGID=1000
      - APP_URL=<my_url>
      - DB_HOST=bookstack_db
      - DB_PORT=3306
      - DB_USER=<user>
      - DB_PASS=<password>
      - DB_DATABASE=bookstackapp
    volumes:
      - B:\Apps\bookstackapp\config:/config
    ports:
      - 6875:80
    restart: unless-stopped
    depends_on:
      - bookstack_db
  bookstack_db:
    image: mysql:8.0.32
    container_name: bookstack_db
    environment:
      - PUID=1000
      - PGID=1000
      - MYSQL_ROOT_PASSWORD=<password>
      - TZ=US/Pacific
      - MYSQL_DATABASE=bookstackapp
      - MYSQL_USER=<user>
      - MYSQL_PASSWORD=<password>
    volumes:
      - B:\Apps\bookstackapp\database:/config
    restart: unless-stopped

Exact BookStack Version

v24.02

Log Content

No response

Hosting Environment

Windows 11, installed via Docker-Compose file (see description)

Originally created by @need4swede on GitHub (Mar 6, 2024). ### Attempted Debugging - [X] I have read the debugging page ### Searched GitHub Issues - [X] I have searched GitHub for the issue. ### Describe the Scenario Windows 11, setup via Docker-Compose. I am not a Docker expert by any means, but for some reason my database volume isn't being binded to my host, but the app config manages to do so just fine. I had some issues getting it all working with MariaDB at first, but I was able to get it working by switching to MySQL instead. But for some reason, the database volume ends up in the container, rather than on my host PC. I've tried removing everything and doing a fresh install of BookStackApp, but the problem persists. Is this a bug, or am I slipping up somewhere? Thank you! ``` version: "2" services: bookstack: image: lscr.io/linuxserver/bookstack container_name: bookstack environment: - PUID=1000 - PGID=1000 - APP_URL=<my_url> - DB_HOST=bookstack_db - DB_PORT=3306 - DB_USER=<user> - DB_PASS=<password> - DB_DATABASE=bookstackapp volumes: - B:\Apps\bookstackapp\config:/config ports: - 6875:80 restart: unless-stopped depends_on: - bookstack_db bookstack_db: image: mysql:8.0.32 container_name: bookstack_db environment: - PUID=1000 - PGID=1000 - MYSQL_ROOT_PASSWORD=<password> - TZ=US/Pacific - MYSQL_DATABASE=bookstackapp - MYSQL_USER=<user> - MYSQL_PASSWORD=<password> volumes: - B:\Apps\bookstackapp\database:/config restart: unless-stopped ``` ### Exact BookStack Version v24.02 ### Log Content _No response_ ### Hosting Environment Windows 11, installed via Docker-Compose file (see description)
OVERLORD added the 🐕 Support label 2026-02-05 09:01:10 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Mar 7, 2024):

Hi @need4swede,
You are mounting the /config path for the database, which is commonly a linxuserver image thing, but not commonly used for other container images like the one you're using which is not a linuxserver-managed image.

Your compose stack indicates you're using this image.
Based upon the guidance there, I think you need to mount to the /var/lib/mysql container path instead for that image.

@ssddanbrown commented on GitHub (Mar 7, 2024): Hi @need4swede, You are mounting the `/config` path for the database, which is commonly a linxuserver image thing, but not commonly used for other container images like the one you're using which is not a linuxserver-managed image. Your compose stack indicates you're using [this image](https://hub.docker.com/_/mysql). Based upon the guidance there, I think you need to mount to the `/var/lib/mysql` container path instead for that image.
Author
Owner

@need4swede commented on GitHub (Mar 7, 2024):

Your compose stack indicates you're using this image. Based upon the guidance there, I think you need to mount to the /var/lib/mysql container path instead for that image.

Thank you for the reply! This seems to work and I can see my database folder now being used. Pardon my ignorance, but is there a way for me to transfer my existing database from the Docker volume to my host - or will I lose all my existing data and have to start fresh?

@need4swede commented on GitHub (Mar 7, 2024): > Your compose stack indicates you're using [this image](https://hub.docker.com/_/mysql). Based upon the guidance there, I think you need to mount to the `/var/lib/mysql` container path instead for that image. Thank you for the reply! This seems to work and I can see my database folder now being used. Pardon my ignorance, but is there a way for me to transfer my existing database from the Docker volume to my host - or will I lose all my existing data and have to start fresh?
Author
Owner

@buckybytes commented on GitHub (Mar 7, 2024):

You should be able to backup and restore your database using mysqldump

@buckybytes commented on GitHub (Mar 7, 2024): You should be able to backup and restore your database using [mysqldump](https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html)
Author
Owner

@ssddanbrown commented on GitHub (Mar 7, 2024):

@need4swede Currently you data will be within the running container. Take care as that data will likely be destroyed if the container is destroyed (Which can occur even if you just take the compose stack down).

As mentioned by @buckybytes, you'd ideally perform a mysqldump of the existing data for safe-keeping, and re-import.
Alternatively, as long as you still use the same exact docker image, you could copy out the /var/lib/mysql files from inside the container. Ideally use a mysqldump though.

I've got a video here on taking a mysqldump via a docker compose stack.
See the "Creating Backups" and "Restoring a from a backup" sections.
It's using the linuxserver mariadb image, but the steps should be pretty similar.

@ssddanbrown commented on GitHub (Mar 7, 2024): @need4swede Currently you data will be within the running container. Take care as that data will likely be destroyed if the container is destroyed (Which can occur even if you just take the compose stack down). As mentioned by @buckybytes, you'd ideally perform a mysqldump of the existing data for safe-keeping, and re-import. Alternatively, as long as you still use the same exact docker image, you could copy out the `/var/lib/mysql` files from inside the container. Ideally use a mysqldump though. I've [got a video here](https://youtu.be/6A8hLuQTkKQ?t=576) on taking a mysqldump via a docker compose stack. See the "Creating Backups" and "Restoring a from a backup" sections. It's using the linuxserver mariadb image, but the steps should be pretty similar.
Author
Owner

@need4swede commented on GitHub (Mar 8, 2024):

@ssddanbrown

Bless you, Dan. Worked like a charm!
Now excuse me while I document the backup process in my BookStackApp.

Cheers!

@need4swede commented on GitHub (Mar 8, 2024): @ssddanbrown Bless you, Dan. Worked like a charm! Now excuse me while I document the backup process in my BookStackApp. Cheers!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#4499