symfony-docker icon indicating copy to clipboard operation
symfony-docker copied to clipboard

Not reachable database DATABASE_URL causes infinite retries to connect and hard to find clear error

Open Zekia opened this issue 3 years ago • 2 comments

If you have an unreachable database specified in DATABASE_URL env at start, the docker-entrypoint.sh exits after 60 retries. Then the docker-compose automatically restarts it.

This gave me 2 false impressions: Something went wrong with caddy (502 caused by the missing socket). Php service was working (service was up/green) but "just" trying to connect when in fact the socket hasn't been created.

I would suggest to remove the exit 1 in the docker-entrypoint.sh in order to have a working caddy and PHP. Let PHP/Symfony handle and display the error.

Zekia avatar Sep 20 '22 21:09 Zekia

Hi!

I recently had this issue with the missing socket and it was a problem with the bin/console file that didn't have execution rights (chmod +x bin/console), can you check yours? I could not explain how it is related

maxhelias avatar Oct 04 '22 20:10 maxhelias

I'm still having the same problem. Rights are looking ok to me on the container: -rwxr-xr-x 1 1000 1000 492 Sep 18 20:41 console

When i originally posted the issue, I think that the sock wasn't even there on the /var/run/php. Now it's here but I get this: status":502,"resp_headers":{"Server":["Caddy"],"Alt-Svc":["h3=\":443\"; ma=2592000"]}} {"level":"error","ts":1665325728.6015813,"logger":"http.log.error","msg":"dialing backend: dial unix /var/run/php/php-fpm.sock: connect: connection refused",

Zekia avatar Oct 09 '22 15:10 Zekia

Can you publish a reproducer with the steps ? So that I can inspect more easily

maxhelias avatar Nov 25 '22 13:11 maxhelias

  1. git clone https://github.com/dunglas/symfony-docker.git
  2. cd symfony-docker-main
  3. docker compose build --pull --no-cache
  4. docker compose up
  5. https://localhost works properly
  6. Creating Makefile from docs/makefile.md
  7. make composer c="require symfony/orm-pack"
  8. make down
  9. make up
  10. https://localhost doesn't work. Returns 502 status.

DanielDrabik avatar Jan 18 '23 20:01 DanielDrabik

@DanielDrabik I followed your steps but unfortunately I didn't succeeds to reproduce. Here my repo : https://github.com/maxhelias/reproduce-289 and and it works as such as it is.

BTW, the require in the makefile doesn't make sense because it's not a regularly used command so you might as well run it directly : docker compose exec php composer require symfony/orm-pack

maxhelias avatar Jan 19 '23 10:01 maxhelias

I had a similar issue, after getting orm-pack from . 1: docker compose down --remove-orphans 2: docker compose build --pull --no-cache to build one more time 3: docker compose up And it helped for me :)

toddltu avatar Jan 19 '23 20:01 toddltu

@maxhelias I was about to use your repo as skeleton cause it works perfectly, but the @toddltu's answer totally helped. Thanks for the replies.

DanielDrabik avatar Jan 19 '23 21:01 DanielDrabik

@DanielDrabik Great! Indeed, each time you modify the Dockerfile you need to rebuild you container. This project can provides all the necessary artifacts to docker when installing a dependancy thanks to symfony/flex but you will have to do the rebuild.

maxhelias avatar Jan 20 '23 08:01 maxhelias

Closing for lack of feedback

maxhelias avatar Apr 28 '23 16:04 maxhelias