BookStackApp / BookStack

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

SQLSTATE[HY000] [2002] No such file or directory #5274

Closed greysmatterweb closed 1 month ago

greysmatterweb commented 1 month ago

Attempted Debugging

Searched GitHub Issues

Describe the Scenario

I have modified the docker-compose file based on your repo.

Getting an error when loading up with docker-compose. MYSQL error.

compose.yaml file :

services:
  bookstack:
    image: lscr.io/linuxserver/bookstack:latest
    container_name: bookstack
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=GB
      - APP_URL=http://127.0.0.1:6875
      - APP_KEY={redacted}
      - DB_HOST=localhost
      - DB_PORT=3306
      - DB_USERNAME=bstack
      - DB_PASSWORD={redacted}
      - DB_DATABASE=bstack
      - QUEUE_CONNECTION= #optional
    volumes:
      - /opt/bookstack/config:/config
    ports:
      - 6875:80
    restart: unless-stopped

When logging on to container I'm not see the MYSQL (or mariaDB) service started. (ps aux)

Using docker version : Docker version 26.1.5+dfsg1, build a72d7cd & docker-compose version : docker-compose version 1.29.2, build unknown

Have tried changing the DB_Host to 127.0.0.1 - Still fails, same error I'm not using any .env file/settings GID/UID match user Have removed and rebuilt

Can't see anything wrong. Any suggestions?

Exact BookStack Version

lscr.io/linuxserver/bookstack:latest ... latest on dockerhub

Log Content

Details

``` $ docker logs -f bookstack [migrations] started [migrations] 01-nginx-site-confs-default: skipped [migrations] 02-default-location: skipped [migrations] done ─────────────────────────────────────── ██╗ ███████╗██╗ ██████╗ ██║ ██╔════╝██║██╔═══██╗ ██║ ███████╗██║██║ ██║ ██║ ╚════██║██║██║ ██║ ███████╗███████║██║╚██████╔╝ ╚══════╝╚══════╝╚═╝ ╚═════╝ Brought to you by linuxserver.io ─────────────────────────────────────── To support LSIO projects visit: https://www.linuxserver.io/donate/ ─────────────────────────────────────── GID/UID ─────────────────────────────────────── User UID: 1000 User GID: 1000 ─────────────────────────────────────── Linuxserver.io version: v24.10-ls169 Build-date: 2024-10-14T15:22:13+00:00 ─────────────────────────────────────── Setting resolver to 127.0.0.11 Setting worker_processes to 8 generating self-signed keys in /config/keys, you can replace these with your own keys if required ...+.+...+..+...+.......+++++++++++++++++++++++++++++++++++++++*..+............+++++++++++++++++++++++++++++++++++++++*........+..++++++ ...+.....+++++++++++++++++++++++++++++++++++++++*.....+........+...+++++++++++++++++++++++++++++++++++++++*.+.......+........+...+.+...+......+.........+..+..........+.....+...+......+.+...++++++ ----- Waiting for DB to be available Illuminate\Database\QueryException SQLSTATE[HY000] [2002] No such file or directory (Connection: mysql, SQL: select table_name as `name`, (data_length + index_length) as `size`, table_comment as `comment`, engine as `engine`, table_collation as `collation` from information_schema.tables where table_schema = 'bstack' and table_type in ('BASE TABLE', 'SYSTEM VERSIONED') order by table_name) at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:829 825▕ $this->getName(), $query, $this->prepareBindings($bindings), $e 826▕ ); 827▕ } 828▕ ➜ 829▕ throw new QueryException( 830▕ $this->getName(), $query, $this->prepareBindings($bindings), $e 831▕ ); 832▕ } 833▕ } +39 vendor frames 40 /app/www/artisan:35 Illuminate\Foundation\Console\Kernel::handle() [custom-init] No custom files found, skipping... ```

Hosting Environment

on Kali Linux VERSION_ID="2024.3" VERSION="2024.3" 6.10.11-amd64

ssddanbrown commented 1 month ago

Hi @greysmatterweb, You'd need to ensure you're also running a database in some way for the BookStack container to connect to. For example, a complete compose may look like:

---
services:
  bookstack:
    image: lscr.io/linuxserver/bookstack:latest
    container_name: bookstack
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/London
      - APP_URL=https://bookstack.example.com
      - DB_HOST=bookstack_db
      - DB_PORT=3306
      - DB_USERNAME=bookstack
      - DB_PASSWORD=<yourdbpass>
      - DB_DATABASE=bookstackapp
    volumes:
      - /path/to/bookstack_app_data:/config
    ports:
      - 6875:80
    restart: unless-stopped
    depends_on:
      - bookstack_db

  bookstack_db:
    image: lscr.io/linuxserver/mariadb:latest
    container_name: bookstack_db
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/London
      - MYSQL_ROOT_PASSWORD=<yourdbpass>
      - MYSQL_DATABASE=bookstackapp
      - MYSQL_USER=bookstack
      - MYSQL_PASSWORD=<yourdbpass>
    volumes:
      - /path/to/bookstack_db_data:/config
    restart: unless-stopped
greysmatterweb commented 1 month ago

Hi

Thanks for you reply. I feel so foolish now. Thought it was running as part of the build You did include this in your instructions. My bad ... lesson learnt .... I need to stop - TLDR

ssddanbrown commented 1 month ago

No worries, I see that linuxserver have recently reduced their example compose file to not include the database, so now it's not so obvious.

Since this is solved I'll therefore close this off.