Bookstack container connection refused

Hello, I’m trying to deploy Bookstack with docker, but i’m just getting started with docker and I think I’m missing something.

This is the docker command I launch:

docker run -d \
  --name=bookstack \
  -e PUID=1000 \
  -e PGID=994 \
  -e APP_URL=http://192.168.1.97:6875 \
  -e DB_HOST=127.0.0.1:3306 \
  -e DB_USER=bookstack \
  -e DB_PASS=bookstack \
  -e DB_DATABASE=bookstackapp \
  -p 6875:80 \
  -v /opt/bookstack/config:/config \
  --restart unless-stopped \
  lscr.io/linuxserver/bookstack:latest

I created a user and group docker with the PID and GID in the run command.
I also set up mysql as normal service, and is accessible by docker user, and the db user bookstack can see and connect to bookstackapp DB:

$ mysql -u bookstack -pbookstack bookstackapp -P 3306 -h 127.0.0.1
Welcome to the MySQL monitor.  Commands end with ; or \g.

User bookstack can connect from anywhere:

mysql> select user,host from mysql.user;
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| bookstack        | %         |

But in the logs I receive the following error, and bookstack return an error 500 white page since it cannot connect to the DB:

Running config - db_user set
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve
nc: getaddrinfo: Name does not resolve

   Illuminate\Database\QueryException

  SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = bookstackapp and table_name = migrations and table_type = 'BASE TABLE')

  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▕     }

      +36 vendor frames
  37  /app/www/artisan:37
      Illuminate\Foundation\Console\Kernel::handle()
cont-init: info: /etc/cont-init.d/50-config exited 0
cont-init: info: running /etc/cont-init.d/85-version-checks
cont-init: info: /etc/cont-init.d/85-version-checks exited 0
cont-init: info: running /etc/cont-init.d/99-custom-files
[custom-init] No custom files found, skipping...
cont-init: info: /etc/cont-init.d/99-custom-files exited 0
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service init-mods: starting
s6-rc: info: service init-mods successfully started
s6-rc: info: service init-mods-package-install: starting
s6-rc: info: service init-mods-package-install successfully started
s6-rc: info: service init-mods-end: starting
s6-rc: info: service init-mods-end successfully started
s6-rc: info: service init-services: starting
s6-rc: info: service init-services successfully started
s6-rc: info: service legacy-services: starting
services-up: info: copying legacy longrun cron (no readiness notification)
services-up: info: copying legacy longrun memcached (no readiness notification)
services-up: info: copying legacy longrun nginx (no readiness notification)
services-up: info: copying legacy longrun php-fpm (no readiness notification)
s6-rc: info: service legacy-services successfully started
s6-rc: info: service 99-ci-service-check: starting
[ls.io-init] done.
s6-rc: info: service 99-ci-service-check successfully started

What could I be missing in the configuration? Be patient, I’m just getting started with Docker :slight_smile:

Don’t use 127.0.0.1/localhost with containers, it doesn’t work how you think it does. Use hostip or container ip.

Thank you man, it was really this simple!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.