BookStackApp / BookStack

A platform to create documentation/wiki content built with PHP & Laravel
https://www.bookstackapp.com/
MIT License
15.43k stars 1.94k forks source link

Bookstack app on docker to Windows host DB issue #5243

Closed sukhoi1 closed 1 month ago

sukhoi1 commented 1 month ago

Attempted Debugging

Searched GitHub Issues

Describe the Scenario

I have installed a Local DB for bookstack on port 3306 to not loose data after PC reboot on Windows. The goal is to start Bookstack instance from docker container which will connect to external DB on Windows Host.

Two params are set

# Source: https://hub.docker.com/r/linuxserver/bookstack
version: "2"
services:
  bookstack_bsv2:
    image: lscr.io/linuxserver/bookstack
    container_name: bookstack_bsv2
    network_mode: "bridge"
    environment:
      - PUID=1000
      - PGID=1000
      - APP_URL=http://172.25.16.1:6885 #6885 <- Step 1
      #- DB_PORT=3306 #3308 <- Step 1
      #- DB_HOST=bookstack_db_bsv1
      #- DB_USER=bookstack
      #- DB_PASS=yourdbpass
      #- DB_DATABASE=bookstackapp
      - DB_PORT=3306
      - DB_HOST=172.25.16.1
      - DB_USER=root
      - DB_PASS=
      - DB_DATABASE=bookstackapp
    volumes:
      - C:\BookStack\config:/config
    ports:
      - 6885:80
    restart: always
    #depends_on:
    #  - bookstack_db_bsv1
  #bookstack_db_bsv1:
  #  image: lscr.io/linuxserver/mariadb
  #  container_name: bookstack_db_bsv1
  #  environment:
  #    - PUID=1000
  #    - PGID=1000
  #    - MYSQL_ROOT_PASSWORD=yourdbrootpass
  #    - TZ=America/New_York
  #    - MYSQL_DATABASE=bookstackapp
  #    - MYSQL_USER=bookstack
  #    - MYSQL_PASSWORD=yourdbpass
  #  #volumes:
  #  #  - bookstack:/config
  #  ports:
  #    - 3308:3306
  #  restart: always

ipconfig port that works (but this is not something generic, like host.docker.internal) host.docker.internal does not work.

image

Is there a way to make Bookstack work in a generic way (without binding to IP 172.25.16.1)? Or I have to recreate a container on each time after reboot with new IP in environment variable?

image

Asked same question here: https://stackoverflow.com/questions/79055630/bookstack-app-on-docker-to-windows-host-db-issue

Exact BookStack Version

latest

Log Content

No response

Hosting Environment

Host: Windows with manually installed DB

ssddanbrown commented 1 month ago

Hi @sukhoi1,

I'm not too sure since I don't really use Windows, and the extra layers required on Windows will likely complicate things (and may differ between normal docker desktop and WSL usage).

I have installed a Local DB for bookstack on port 3306 to not loose data after PC reboot on Windows.

Why will you loose data? If storage volumes are configured correctly you should not be loosing data. The BookStack container also stores files which are expected to be used via storage volumes, so if there's something risking the database files then there may also be a risk to app files (uploads, images etc...)

sukhoi1 commented 1 month ago

Hi @ssddanbrown, thank you for high-level hint.

This approach was skipped. image

I started to test a Windows-approach with both containers: Bookstack and MariaDB.

SQLSTATE[HY000] [2002] Connection refused (SQL: alter table pages add index pages_template_index(template)) image

# Source: https://hub.docker.com/r/linuxserver/bookstack
version: "2"
services:
  bookstack_bsv1:
    image: lscr.io/linuxserver/bookstack #lscr.io/linuxserver/bookstack:23.02.2 # lscr.io/linuxserver/bookstack <- Step 5
    container_name: bookstack_bsv1
    environment:
      - PUID=1000
      - PGID=1000
      - APP_URL=http://localhost:6885
      - DB_PORT=3306 #3308 <- Step 1
      - DB_HOST=bookstack_db_bsv1
      - DB_USER=bookstack
      - DB_PASS=yourdbpass
      - DB_DATABASE=bookstackapp
    #volumes:
    #  - C:\BookStack\config:/config
    ports:
      - 6885:80
    restart: always
    depends_on:
      - bookstack_db_bsv1
  bookstack_db_bsv1:
    image: lscr.io/linuxserver/mariadb
    #image: mysql:8.0.32 # <- Step 3 https://github.com/linuxserver/docker-bookstack/issues/125 error for Windows mount
    container_name: bookstack_db_bsv1
    environment:
      - PUID=1000
      - PGID=1000
      - MYSQL_ROOT_PASSWORD=yourdbrootpass
      - TZ=America/New_York
      - MYSQL_DATABASE=bookstackapp
      - MYSQL_USER=bookstack
      - MYSQL_PASSWORD=yourdbpass
    volumes:
      - ./config:/config # <- Step 2
      - ./mysql-data:/var/lib/mysql # <- Step 4 for mysql db folder is different
    ports:
      - 3308:3306
    restart: always

But there is a fix for this Windows problem: here https://github.com/linuxserver/docker-bookstack/issues/125 the final post.

With this compose file volumes are created and files are visible. When the containers are dropped and recreated, then docker compose is up once again (folders are left as is) Boostack login starts and data is restored with images on WIndows.

services:
  bookstack:
    image: lscr.io/linuxserver/bookstack:23.02.2
    container_name: bookstack
    environment:
      - PUID=1000
      - PGID=1000
      - APP_URL=http://localhost:6875
      - APP_DEBUG=true
      - STORAGE_TYPE=local
      - DB_HOST=bookstack_db
      - DB_PORT=3306
      - DB_USER=bookstack
      - DB_PASSWORD=12345678
      - DB_DATABASE=bookstackapp
    volumes:
      - ./bookstackdata:/config
    ports:
      - 6875:80
    restart: unless-stopped
    depends_on:
      - bookstack_db

  bookstack_db:
    #image: mariadb:10.6.12
    image: mysql:8.0.32
    container_name: bookstack_db
    ports:
      - 3308:3306 # 3308 is a DB port visible on HOST
    environment:
      - PUID=1000
      - PGID=1000
      - MYSQL_ROOT_PASSWORD=password
      - TZ=America/New_York
      - MYSQL_DATABASE=bookstackapp
      - MYSQL_USER=bookstack
      - MYSQL_PASSWORD=12345678
      - TERM=dumb
    volumes:
      - ./bookstackdbdata:/config
      - ./db-store:/var/lib/mysql
    restart: unless-stopped
sukhoi1 commented 1 month ago

@ssddanbrown now it is not clear how to upgrade docker container images. Cannot find info on image tag correlation, such as : lscr.io/linuxserver/bookstack:23.02.2 to mysql:8.0.32. lscr.io/linuxserver/bookstack:latest to mysql:latest results into a broken Bookstack instance.