I found a similar question here but it didn't quite answer my question.
I've always installed my stack locally for development, NginX, PHP7, MySQL, and Couchbase. No Problems.
Now I have to work on a project that requires a lower version of PHP... And my team will have to work on it as well, so I've looked to Docker to try to find the solution.
In my existing NGINX conf files I send the requests off to php-fpm like this
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_ignore_client_abort on;
fastcgi_param SERVER_NAME $http_host;
}
See the line
fastcgi_pass 127.0.0.1:9000;
?
I was hoping to be able to create a docker container running a specific version of PHP and write it into the server block as above but with
fastcgi_pass 172.17.0.1:9000;
Where 172.17.0.1 is the IP of the container.
I have used, very simply,
FROM php:7.1-fpm
EXPOSE 9000
As my dockerfile. I can build an image, run the container, run bash in the container and see that PHP -I and PHP -v return what I expect.
Running docker inspect has given me two IP addresses, 172.17.0.1, and 172.17.0.2 (I've tried both in the example above)
However, this set up is not working - when I try to visit the site in a browser I get an NGINX 504 gateway timeout error.
Guessing I'm missing something, but not sure what.
Happy to use docker compose if I need to, happy to mount volumes into the container if I need to. Just not sure what I need!:)