-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
I'm using Nginx together with PHP-FPM, both in their own container. At first the PHP-FPM container looks fine as a request using cgi-fcgi
gives me a response. But once I make a call to my website I get a 502 Bad Gateway error and cgi-fcgi
also states that it can't connect after this.
I managed to fix this again though. I exec
into the PHP-FPM container and put out a request, e.g., curl 'http://google.com'
or apt-get update
. After doing this my website works again (and thus cgi-fcgi
works as well).
This is my docker-compose.yml
:
c-nginx:
image: nginx:1.9.9
volumes:
- ../www:/usr/share/nginx/html
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx-site.conf:/etc/nginx/conf.d/default.conf:ro
- ./restrictions.conf:/etc/nginx/global/restrictions.conf:ro
links:
- c-php-fpm
c-php-fpm:
image: php:5.6.16-fpm
volumes:
- ../www:/usr/share/nginx/html
I tried PHP-FPM versions 5.6.17 and 7.0.2 as well, but the results were the same.
I also tried using docker run
instead of docker-compose
, still the same results:
sudo docker run --name c-php-fpm -v /srv/nginx-php/www:/usr/share/nginx/html -d php:5.6.16-fpm
sudo docker run --name c-nginx --link c-php-fpm -v /srv/nginx-php/www:/usr/share/nginx/html -v /srv/nginx-php/docker:/etc/nginx/nginx -v /srv/nginx-php/docker/temp-nginx-site-conf:/etc/nginx/conf.d -v /srv/nginx-php/docker/temp-global:/etc/nginx/global/ -d nginx:1.9.9
It took me quite time to get to this problem description, but I have no idea what is causing this behavior. I want this setup to work out of the box, without this weird fix I use now. So does anybody have any ideas or things for me to try?