api-platform: "Still waiting for db to be ready... Or maybe the db is not reachable."
API Platform version(s) affected: 2.5.7
Description
On a fresh install of API Platform package (.tar.gz), after running docker-compose up, the PHP container is trying to run the command bin/console doctrine:query:sql "SELECT 1" to see if the DB container is up and running.
The problem is that bin/console file doesn’t have the executable flag in the container, so PHP container can’t see it’s connected to DB and exited with an error.
How to reproduce
- Download the last version in .tar.gz
- Uncompress the directory to a location
- Configure the DB password in docker-compose.yaml (or not, but I did it)
- Start docker-compose (pull > up)
- Look at the logs to see the message
Still waiting for db to be ready... Or maybe the db is not reachable. x attempts left
Possible Solution
Applying +x flag to bin/console
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (5 by maintainers)
For me this was cause by removing
apk add pdo_pgsql \in my api/DockerfileI copy some of another Dockerfile, and replace this by
pdo_mysql \I search a lot on the web and found nothing, hope it can helps someone
Hi, I have also this problem. For a week now, I don’t now why it’s work on my local (Windows) but not in my server (VPS at OVH)
Process
git cloneor package from the repositorydocker-compose up --build.Results Local:
200 /pingServer:
Still waiting for db to be ready... Or maybe the db is not reachable.I juste solve my problem with
chmod +x api/bin/console🤯I started to but…
I mixed up two bugs reports for the same kind of problem. The other one was not related to api-platform but involved bin/console too.
So, here the problem is for the “Still waiting” because bin/console is not executable in some situations. It’s not because of a composer doing a cache:clear… I mixed up.
Back to this problem:
I tried different ways to install and run api-platform.
I did chmod +x on bin/console under WSL2, ran docker-compose up again and the problem was solved.
So, it can’t be fixed in the Dockerfile. It’s a Windows and/or WSL2 problem only.
The problem is because of Windows. Even with the .tar.gz file 😕
I checked permissions for bin/console on the repo. It’s 0755, so it’s not a repo or archive problem. It’s not the most elegant way to solve, once for all, this problem but chmod +x is the most efficient way.
You’re already did it in line https://github.com/api-platform/api-platform/blob/master/api/Dockerfile#L105 but it’s after the first
composer installcommand in line https://github.com/api-platform/api-platform/blob/master/api/Dockerfile#L86Composer do a
bin/console cache:clearafter an install or update, so it needs to have bin/console to be executable.composer.json:I know you don’t like this, but… Moving the
chmod +x bin/consoleis the best way to solve this. A fresh Symfony have bin/console executable.It seems untaring into a wsl2 folder from Windows doesn’t keep some linux permissions, even with a .tar.gz archive.
Maybe just adding a chmod +x bin/console before the first composer install, in the Dockerfile, can solve this problem for wsl2 devs ? It’s a lot easier to untar files from Windows to a wsl2 folder than doing all the command lines directly into wsl2. 😉
I used the .tar.x file and untar under wsl2.