Unable to start Docker development environment due to wait-for-it (database) #2290

Closed
opened 2026-02-05 03:34:50 +03:00 by OVERLORD · 2 comments
Owner

Originally created by @russjr08 on GitHub (Jun 11, 2021).

Describe the bug
I am trying to setup a local development environment for BookStack using Docker, and am having issues with the application waiting for the database to be ready, and times out.

Steps To Reproduce
Steps to reproduce the behavior:

  1. Copy .env.example to .env file with APP_ENV=local, updated APP_KEY, and APP_URL to http://localhost:8080 (tried explicitly setting DEV_PORT=8080 as well)
  2. Run docker-compose up
  3. Wait for services to come up
  4. Database times out:
app_1      | wait-for-it: timeout occurred after waiting 45 seconds for db:3306
bookstack_app_1 exited with code 124

Expected behavior
BookStack should launch and be ready to view/access.

Your Configuration (please complete the following information):

  • Exact BookStack Version (Found in settings): 21.0.5
  • PHP Version: 7.4 (Included with the bundled docker configuration)
  • Hosting Method (Nginx/Apache/Docker): Docker

Additional context
The log for my docker-compose up attempt can be found over here.

My .env file is as follows

My docker-compose.yml file is also as follows

System:
Docker version 20.10.7
docker-compose version 1.29.2
Operating System: EndeavourOS (Arch Linux derivative)

I'm not sure if I am potentially missing something here to get the environment setup, or if there is actually an issue. From what I can see based off the docker-compose logs, MySQL is starting up just fine without any errors, however the application never connects to it, and times out while waiting for it to be "ready".

Please certainly let me know if there's anything else I can include that might help!

Originally created by @russjr08 on GitHub (Jun 11, 2021). **Describe the bug** I am trying to setup a local development environment for BookStack using Docker, and am having issues with the application waiting for the database to be ready, and times out. **Steps To Reproduce** Steps to reproduce the behavior: 1. Copy `.env.example` to `.env` file with `APP_ENV=local`, updated `APP_KEY`, and `APP_URL` to `http://localhost:8080` (tried explicitly setting `DEV_PORT=8080` as well) 2. Run `docker-compose up` 3. Wait for services to come up 4. Database times out: ``` app_1 | wait-for-it: timeout occurred after waiting 45 seconds for db:3306 bookstack_app_1 exited with code 124 ``` **Expected behavior** BookStack should launch and be ready to view/access. **Your Configuration (please complete the following information):** - Exact BookStack Version (Found in settings): 21.0.5 - PHP Version: 7.4 (Included with the bundled docker configuration) - Hosting Method (Nginx/Apache/Docker): Docker **Additional context** The log for my `docker-compose up` attempt can be found [over here](https://paste.russ.network/code/GrabbingStob). My `.env` file is [as follows](https://paste.russ.network/code/RuminatedTotter) My `docker-compose.yml` file is also [as follows](https://paste.russ.network/code/UlcerateAfterglows) System: Docker version `20.10.7` docker-compose version `1.29.2` Operating System: EndeavourOS (Arch Linux derivative) I'm not sure if I am potentially missing something here to get the environment setup, or if there is actually an issue. From what I can see based off the docker-compose logs, MySQL is starting up just fine without any errors, however the application never connects to it, and times out while waiting for it to be "ready". Please certainly let me know if there's anything else I can include that might help!
Author
Owner

@ssddanbrown commented on GitHub (Jun 11, 2021):

Hi @russjr08,

Just tested the dev docker setup on my Fedora 34 install and all seems to be still working via my testing.
Can't see any reason why yours might be failing based on those logs, Database seems alive and ready before wait-for-it starts. Might be some internal docker networking issues in a certain case maybe?

You could try just removing the wait-for-it line since your logs show the DB is ready before then anyway. Then, if the next line (php artisan migrate) fails it could be a sign that the app container just has no network visibility to the db container at the expected address.

@ssddanbrown commented on GitHub (Jun 11, 2021): Hi @russjr08, Just tested the dev docker setup on my Fedora 34 install and all seems to be still working via my testing. Can't see any reason why yours might be failing based on those logs, Database seems alive and ready before wait-for-it starts. Might be some internal docker networking issues in a certain case maybe? You could try just removing the [wait-for-it line](https://github.com/BookStackApp/BookStack/blob/master/dev/docker/entrypoint.app.sh#L11) since your logs show the DB is ready before then anyway. Then, if the next line (`php artisan migrate`) fails it could be a sign that the app container just has no network visibility to the db container at the expected address.
Author
Owner

@russjr08 commented on GitHub (Jun 11, 2021):

Hello @ssddanbrown,

Thanks for getting back to me! I found that you were correct, the database was failing to be exposed/reachable from the app container.

Given this, I was able to add the following to my docker-compose.yml file:

app:
    links:
      - "db:db"

Which then allowed the app container to reach the database, run migrations, and finally bring the web server online! I'm not sure as to what has gone wrong on my system to require me to explicitly link the two together (my knowledge on Docker is still very new), but nonetheless I'm glad a solution exists!

Given that on your system these changes weren't needed, I'll assume that it is indeed my system at fault, and will close the issue with this - especially since those issues would be out-of-scope for this repo, and would probably need to be made on docker's side or such. I appreciate your time!

@russjr08 commented on GitHub (Jun 11, 2021): Hello @ssddanbrown, Thanks for getting back to me! I found that [you were correct](https://paste.russ.network/code/BlossomVower), the database was failing to be exposed/reachable from the app container. Given this, I was able to add the following to my `docker-compose.yml` file: ``` app: links: - "db:db" ``` Which then allowed the app container to reach the database, run migrations, and finally bring the web server online! I'm not sure as to what has gone wrong on my system to require me to explicitly link the two together (my knowledge on Docker is still very new), but nonetheless I'm glad a solution exists! Given that on your system these changes weren't needed, I'll assume that it is indeed my system at fault, and will close the issue with this - especially since those issues would be out-of-scope for this repo, and would probably need to be made on docker's side or such. I appreciate your time!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#2290