Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bookstack app on docker to Windows host DB issue #5243

Open
2 tasks done
sukhoi1 opened this issue Oct 4, 2024 · 3 comments
Open
2 tasks done

Bookstack app on docker to Windows host DB issue #5243

sukhoi1 opened this issue Oct 4, 2024 · 3 comments

Comments

@sukhoi1
Copy link

sukhoi1 commented Oct 4, 2024

Attempted Debugging

  • I have read the debugging page

Searched GitHub Issues

  • I have searched GitHub for the issue.

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

  • APP_URL=http://172.25.16.1:6885 #6885 <- Step 1
  • DB_HOST=172.25.16.1
    where IP is taken after reboot each time new: from ipconfig 172.25.16.1
    docker-compose.yml
# 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
Copy link
Member

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
Copy link
Author

sukhoi1 commented Oct 5, 2024

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 linuxserver/docker-bookstack#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
Copy link
Author

sukhoi1 commented Oct 5, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants