linuxserver / docker-bookstack

A Docker container for the BookStack documentation wiki
GNU General Public License v3.0
747 stars 108 forks source link

[MIGRATION] Connection refused on migration #160

Closed spreedated closed 1 year ago

spreedated commented 1 year ago

Is there an existing issue for this?

Current Behavior

Error message on migration

Expected Behavior

I guess there shouldn't be an error on the migration process

Steps To Reproduce

Install freshly container with docker-compose. As you can see, I've tried several methods, also cleaning cache & migrate commands. Nothing seems to work.

Environment

- HOST-OS: Windows
- How docker service was installed: Docker is running fine.

CPU architecture

x86-64

Docker creation

version: "3.9"
services:
  bookstack:
    restart: always
    volumes:
      - c:\docker\bookstack\bstack:/config
    ports:
      - "6875:80"
    environment:
      - PUID=1000
      - PGID=1000
      - APP_URL=http://cdocker
      - DB_HOST=bookstack_db
      - DB_PORT=3306
      - DB_USER=bookstack
      - DB_PASS=mypass
      - DB_USERNAME=bookstack
      - DB_PASSWORD=mypass
      - DB_DATABASE=bookstackapp
    image: "lscr.io/linuxserver/bookstack"
    container_name: bookstack
    depends_on:
      - bookstack_db
  bookstack_db:
    image: lscr.io/linuxserver/mariadb
    container_name: bookstack_db
    environment:
      - PUID=1000
      - PGID=1000
      - MYSQL_ROOT_PASSWORD=d3w34d2ds
      - TZ=Europe/Berlin
      - MYSQL_DATABASE=bookstackapp
      - MYSQL_USER=bookstack
      - MYSQL_PASSWORD=mypass
    volumes:
      - c:\docker\bookstack\db:/config
    restart: unless-stopped

Container logs

Migrating: 2018_08_04_115700_create_bookshelves_table
Migrated:  2018_08_04_115700_create_bookshelves_table (2,068.94ms)
Migrating: 2019_07_07_112515_add_template_support

   Illuminate\Database\QueryException

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

  at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:712
    708▕         // If an exception occurs when attempting to run a query, we'll format the error
    709▕         // message to include the bindings with SQL, which will make this exception a
    710▕         // lot more helpful to the developer instead of just the database's errors.
    711▕         catch (Exception $e) {
  ➜ 712▕             throw new QueryException(
    713▕                 $query, $this->prepareBindings($bindings), $e
    714▕             );
    715▕         }
    716▕     }

      +18 vendor frames
  19  /app/www/database/migrations/2019_07_07_112515_add_template_support.php:20
      Illuminate\Support\Facades\Facade::__callStatic()

      +22 vendor frames
  42  /app/www/artisan:37
      Illuminate\Foundation\Console\Kernel::handle()
[custom-init] No custom files found, skipping...
[ls.io-init] done.
github-actions[bot] commented 1 year ago

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

ssddanbrown commented 1 year ago

It's probably worth reading through #125 which has the same kind of scenario, where the problem is due to things not working as expected (or not keeping up) when volumes are mounted to a windows host filesystem.

spreedated commented 1 year ago

Well, thanks for your answer, but, it does work indeed! But I wouldn't consider this as a workaround, since all data will be lost when the container is dropped.

Is there another option? - I cannot use linux as a host.

aptalca commented 1 year ago

When you use linux containers on windows, mounting windows paths for the config folders is a really bad idea. It is using a compatilibility layer for ntfs, which causes lots of issues like the one you're running into. There is nothing we can do about it.

What we recommend on Windows is to use docker via compose in a wsl linux app/vm, and mount the linux paths for the config folders. Then there is no compatibility layer needed between the container and the filesystem.

You can still access that path from Windows file explorer so there is no downside.

For data and media folders, it is generally ok to mount windows paths because the compatibility layer works fine for simple read and write operations.

Simply copy the data from windows into the wsl container (in archive mode) and recreate the container with the new path. You won't lose any data.