Multiple versions of PHP through Nginx in Docker Multiple versions of PHP through Nginx in Docker docker docker

Multiple versions of PHP through Nginx in Docker


Ok I solved it, quite dummy mistake. For some reason I assumed that if I expose the port 9001 like this:

docker run --name php5 \    -v /html1:/var/www/html/site1 \    -d -p 9001:9000 php:5.6-fpm

then this port 9001 should be used in Nginx container which is connected to the other php5 container. This is wrong because the exposed network connection is different than linked one.

So the proper site1 config should be like this (the port is also 9000):

server {        listen 80 default_server;        server_name site1;        root /var/www/html/site1/;        index index.php index.html index.htm default.html default.htm;        fastcgi_buffers 8 16k;        fastcgi_buffer_size 32k;        fastcgi_read_timeout 180;        location ~ \.php$ {            fastcgi_pass  php5:9000; # <-- BOOOM!            fastcgi_index index.php;            include fastcgi_params;            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;            fastcgi_param SERVER_NAME $server_name;        }}