Nginx and php-fpm docker compose - php

I'm trying to create a development environnement for PHP project with Docker-compose.
I just created a docker-compose file that contains 3 docker:
Application: that mounts my code volume
Php: that runs php5-fpm
Nginx: that runs the nginx web server.
I can get an html file through my web server but when I try with a php file I get a 502 Bad Request error.
Error.log:
2016/09/19 16:51:18 [error] 8#0: *2 connect() failed (111: Connection refused) while connecting to upstream, client: 172.17.0.1, server: xxx, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://172.17.0.3:9000", host: "xxx"
I think that nginx can't connect to php.
Here is my docker-compose file:
# import the code and bind it on /var/www
application:
build: code
volumes:
- ./sites:/var/www/
tty: true
# php container
php:
build: php-fpm
volumes_from:
- application
expose:
- 9000:9000
volumes:
- ./logs/php5-fpm/:/var/log
# nginx container
nginx:
build: nginx
ports:
- 80:80
links:
- php
volumes_from:
- application
volumes:
- ./logs/nginx:/var/log/nginx
php-fpm/Dockerfile:
FROM debian:jessie
RUN apt-get update && apt-get install -y php5-common php5-cli php5-fpm php5-mcrypt php5-mysql php5-gd php5-imagick php5-curl php5-intl php5-memcache php5-imap
RUN usermod -u 1000 www-data
CMD ["php5-fpm", "-F"]
EXPOSE 9000
nginx/Dockerfile:
FROM debian:jessie
RUN apt-get update && apt-get install -y nginx
ADD nginx.conf /etc/nginx
ADD test.conf /etc/nginx/sites-available/
RUN ln -s /etc/nginx/sites-available/test.conf /etc/nginx/sites-enabled/test.conf
RUN rm /etc/nginx/sites-enabled/default
RUN echo "upstream php-upstream { server php:9000; }" > /etc/nginx/conf.d/upstream.conf
RUN usermod -u 1000 www-data
CMD ["nginx"]
EXPOSE 80
nginx/nginx.conf:
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 2048;
multi_accept on;
use epoll;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log off;
error_log off;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
daemon off;
nginx/test.conf:
server {
listen 80;
server_name xxx;
root /var/www/test;
location ~ \.php$ {
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
error_log /var/log/nginx/test_error.log;
access_log /var/log/nginx/test_access.log;
}
There is no error when launching the docker-compose.
Can someone help me ?
Thanks

Related

502 Bad Gateway Docker Symfony Nginx

I have a problem with my docker configuration, my home page on localhost return always 502 Bad Gateway.
Here you can see the architecture of the projet :
https://i.stack.imgur.com/Bfc24.png
the four container running :
https://ibb.co/XpQvnXj
I can access to phpmyadmin :
https://ibb.co/FXLqg8B
But when I go to the nginx port I have this issue :
https://ibb.co/2vs72jF
And this is the contents of the files.
docker-compose.yml :
version: '3'
services:
php:
build:
context: ./php
ports:
- "9000:9000"
volumes:
- ../symfony:/var/www
nginx:
container_name: "nginx"
build:
context: ./nginx
volumes:
- ../symfony:/var/www
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./logs:/var/log
depends_on:
- php
ports:
- "8081:80"
db:
image: mysql:5.6
restart: always
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
phpmyadmin:
image: phpmyadmin
restart: always
ports:
- 8080:80
environment:
PMA_HOST: db
depends_on:
- db
php/Dockerfile :
FROM php:8.0.3-fpm
RUN apt-get update \
&& apt-get install -y --no-install-recommends locales apt-utils git libicu-dev g++ libpng-dev libxml2-dev libzip-dev libonig-dev libxslt-dev;
RUN curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony
RUN curl -sSk https://getcomposer.org/installer | php -- && \
mv composer.phar /usr/local/bin/composer
RUN docker-php-ext-configure intl
RUN docker-php-ext-install mysqli
RUN docker-php-ext-install pdo pdo_mysql gd opcache intl zip calendar dom mbstring zip gd xsl
RUN pecl install apcu && docker-php-ext-enable apcu
WORKDIR /var/www
CMD composer install ; php-fpm
EXPOSE 9000
nginx/Dockerfile :
FROM nginx:alpine
WORKDIR /var/www
CMD ["nginx"]
EXPOSE 80
nginx/nginx.conf :
user nginx;
worker_processes 4;
daemon off;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
sendfile on;
keepalive_timeout 65;
upstream phpserver {
server php:9000;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;
root /var/www/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass phpserver;
fastcgi_index index.php;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 600;
include fastcgi_params;
}
location ~ /\.ht {
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
deny all;
}
}
}
error.log :
2021/10/13 13:53:04 [error] 25#25: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.16.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://192.168.16.3:9000", host: "localhost:8081"
2021/10/13 13:53:04 [error] 25#25: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.16.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://192.168.16.3:9000", host: "localhost:8081", referrer: "http://localhost:8081/"
I'm new to Docker so the problem is probably obvious

failed (104: Connection reset by peer) while reading response header from upstream in docker and ubuntu

I created a DockerFile like below
FROM ubuntu:18.04
MAINTAINER Amin Keshavarz <ak_1596#yahoo.com>
# Add your github access token if needed in composer update as arg or env var.
ARG github_access_token
ENV github_access_token=${github_access_token}
ENV DEBIAN_FRONTEND=noninteractive
# Install dependency packages
RUN apt-get update && apt-get install -yq --no-install-recommends \
git \
curl \
ca-certificates \
# php \
php7.2-fpm php7.2-common \
php7.2-mongodb php-pear php7.2-dev
RUN apt-get install -y build-essential
# Install mongodb driver
RUN pecl install mongodb
#RUN echo "extension=mongodb.so" >> /etc/php/7.2/fpm/php.ini
#RUN echo "extension=mongodb.so" >> /etc/php/7.2/cli/php.ini
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN apt-get install -y php7.2-mbstring \
php7.2-intl \
php7.2-soap \
php7.2-curl \
php7.2-imap \
php7.2-zmq \
php7.2-bcmath \
php7.2-gd \
php7.2-zip
# Add working directory and copy files into that.
RUN mkdir /app
VOLUME /app
WORKDIR /app
COPY . /app
# Start application installation by composer update command.
#RUN composer config -g github-oauth.github.com $github_access_token
RUN composer global require fxp/composer-asset-plugin
#RUN composer update -vvv
ENTRYPOINT service php7.2-fpm start && /bin/bash
CMD ["php-fpm"]
EXPOSE 9000
And using below docke-compose.yml
version: "3"
services:
web:
build:
context: .
dockerfile: ./docker/Dockerfile
container_name: "crm_web"
tty: true
ports:
- "9000:9000"
networks:
- default
volumes:
- .:/app
nginx:
image: nginx:1.10.3
container_name: "crm_nginx"
ports:
- 8080:80
restart: always
volumes:
- ./docker/nginx.conf:/etc/nginx/conf.d/default.conf
- .:/app
links:
- web
depends_on:
- web
And has below nginx.conf
server {
client_max_body_size 100M;
set $host_path "/app";
access_log /app/log/access.log main;
server_name _ localhost;
root $host_path/;
set $yii_bootstrap "index.php";
charset utf-8;
location / {
index index.html $yii_bootstrap;
try_files $uri $uri/ /$yii_bootstrap?$args;
}
location ~ ^/(protected|framework|themes/\w+/views) {
deny all;
}
#avoid processing of calls to unexisting static files by yii
location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
try_files $uri =404;
}
# pass the PHP scripts to FastCGI server listening on web:9000
#
location ~ \.php {
fastcgi_split_path_info ^(.+\.php)(.*)$;
#let yii catch the calls to unexising PHP files
set $fsn /$yii_bootstrap;
if (-f $document_root$fastcgi_script_name){
set $fsn $fastcgi_script_name;
}
fastcgi_pass web:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fsn;
#PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fsn;
}
# prevent nginx from serving dotfiles (.htaccess, .svn, .git, etc.)
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
}
But when i try to connect my host http://localhost:8080 i get below error in my console from docker:
crm_nginx | 2018/12/03 14:48:14 [error] 28#28: *17 recv() failed (104:
Connection reset by peer) while reading response header from upstream,
client: 172.18.0.1, server: _, request: "GET /web/ HTTP/1.1",
upstream: "fastcgi://172.18.0.2:9000", host: "localhost:8080"
And get 502 Bad Gateway in browser.
Can you help me solve this problem?
What i missed?
Add below line into your Dockerfile
RUN sed -i "s|;*listen\s*=\s*/run/php/php7.2-fpm.sock|listen = 9000|g" /etc/php/7.2/fpm/pool.d/www.conf && \
sed -i "s|;*listen\s*=\s*/||g" /etc/php/7.2/fpm/php-fpm.conf
This will tell to php7.2-fpm listen to port 9000 instead /run/php/php7.2-fpm.sock.
Be careful to do not add IP address before port like 127.0.0.1:9000 because this forces PHP to listen to port and IP at the same time but you don't know what is container ip address.
I found my answer here and you can refer to that:
https://www.digitalocean.com/community/questions/nginx-error-111-connection-refused
fastcgi_pass web:9000;
try changing this line to:
fastcgi_pass crm_web:9000;
since you have container_name: "crm_web" in your docker-compose.yml

Multiple process for user

I looking how allow run multiple process for one user in symfony.
I have this behavior in Symfony / Nginx / Php FPM
but I test in clean symfony and php webserver:
composer create-project symfony/website-skeleton my-project
this is docker config :
version: "3.1"
services:
webserver:
image: nginx:alpine
container_name: viz-webserver
working_dir: /application
volumes:
- .:/application
- ./docker/nginx/nginx_all.conf:/etc/nginx/nginx.conf
networks:
itb_net:
ipv4_address: 10.2.0.6
php-fpm:
build: itb_docker/php-fpm
container_name: php-fpm
working_dir: /application
networks:
itb_net:
ipv4_address: 10.2.0.8
volumes:
- ~/.ssh/:/root/.ssh/
- .:/application
- ./docker/php-fpm/php-ini-overrides.ini:/etc/php/7.2/fpm/conf.d/99-overrides.ini
- ./.aws/credentials:/var/www/.aws/credentials
php-ini-overrides.ini
upload_max_filesize = 200M
post_max_size = 208M
memory_limit = 4048M
php-fpm Dockerfile
FROM phpdockerio/php72-fpm:latest
WORKDIR "/application"
# Fix debconf warnings upon build
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get -y --no-install-recommends install php-zip php-xdebug php-gd php-xml php7.2-mysql php7.2-intl php7.2-tidy php7.2-xmlrpc php7.2-soap php7.2-bcmath php-mbstring php-curl\
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
# Install git
RUN apt-get update \
&& apt-get -y install git acl wkhtmltopdf xvfb \
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
nginx
user nginx;
worker_processes 2;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /dev/stdout main;
#sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
gzip on;
server {
# limit_conn conn_limit_per_ip 10;
# limit_req zone=req_limit_per_ip burst=10 nodelay;
fastcgi_keep_conn on;
#proxy_buffering off;
gzip off;
listen 80 default;
client_max_body_size 208M;
access_log /var/log/nginx/application.access.log;
root /application/public;
rewrite ^/index\.php/?(.*)$ /$1 permanent;
try_files $uri #rewriteapp;
location #rewriteapp {
rewrite ^(.*)$ /index.php/$1 last;
}
# Deny all . files
location ~ /\. {
deny all;
}
location ~ ^/(index)\.php(/|$) {
fastcgi_pass php-fpm:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_index app_dev.php;
send_timeout 1800;
fastcgi_read_timeout 1800;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE "error_log=/var/log/nginx/application_php_errors.log";
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
include fastcgi_params;
}
# Statics
location /(bundles|media) {
access_log off;
expires 30d;
try_files $uri #rewriteapp;
}}
}
test controller:
class TestController extends Controller
{
/**
* #Route("/test1")
*/
public function aAction(){
$i = 0;
while($i<50){
echo "$i<BR>";
$i++;
sleep(2);
}
}
/**
* #Route("/test2")
*/
public function bAction(){
return new Response('OK');
}
}
and same result - go to /test1 and test2 in second tab = second tab wait to first finish.
The built-in PHP server is single-threaded. If you get a long or hanged request it can't serve the next request until the thread is free to serve the incoming request.
As per http://php.net/manual/en/features.commandline.webserver.php
The web server runs a only one single-threaded process, so PHP applications will stall if a request is blocked.

Nginx+PHP-FPM: connection refused while connecting to upstream (502)

I know there's a ton of posts regarding 502 Bad Gateway, but I haven't been able to solve this problem. I'm using Docker Compose to create separate containers for Nginx and PHP-FPM.
Error I get loading PHP files in the browser (HTML files render fine):
tc-web | 2018/01/22 19:22:46 [error] 5#5: *4 connect() failed (111: Connection refused) while connecting to upstream, client: 172.18.0.1, server: localhost, request: "GET /info.php HTTP/1.1", upstream: "fastcgi://172.18.0.2:9000", host: "localhost:8080"
tc-web | 172.18.0.1 - - [22/Jan/2018:19:22:46 +0000] "GET /info.php HTTP/1.1" 502 575 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
I've tried tweaking the various configs, using Unix socket, etc., for hours, and I still get 502 errors with PHP files. Can you spot what's wrong?
Here are all required files..
docker-composer.yml:
version: '3'
services:
web:
build:
context: ./docker/nginx
image: tc-web:0.1.0
container_name: tc-web
volumes:
# test files
- ./temp.html:/var/www/html/index.html
- ./temp.php:/var/www/html/info.php
ports:
- 8080:80
depends_on:
- php-fpm
php-fpm:
build:
context: ./docker/php-fpm
image: tc-php:0.1.0
container_name: tc-php
volumes:
- ./temp.html:/var/www/html/index.html
- ./temp.php:/var/www/html/info.php
docker/nginx/Dockerfile:
FROM nginx:1.13.8
# Install programs
RUN apt-get update
RUN apt-get install -y nano && \
apt-get install -y git && \
apt-get install -y procps
RUN mkdir -p /var/www/html
COPY nginx.conf /etc/nginx/nginx.conf
COPY default.conf /etc/nginx/conf.d/default.conf
docker/nginx/nginx.conf:
user www-data;
worker_processes 1;
# error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/default.conf;
}
docker/nginx/default.conf:
server {
listen 80;
server_name localhost;
root /var/www/html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~* \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
docker/php-fpm/Dockerfile:
FROM php:7.0-fpm
# Install programs
RUN apt-get update
RUN apt-get install -y nano && \
apt-get install -y procps
RUN mkdir -p /var/www/html
COPY php-fpm.conf /usr/local/etc/php-fpm.conf
COPY www.conf /usr/local/etc/php-fpm.d/www.conf
docker/php-fpm/php-fpm.conf:
[global]
include=etc/php-fpm.d/www.conf
docker/php-fpm/www.conf:
[global]
;daemonize = no
; if we send this to /proc/self/fd/1, it never appears
error_log = /proc/self/fd/2
[www]
user = www-data
group = www-data
listen = 127.0.0.1:9000
;listen = /var/run/php-fpm/php7-fpm.sock
;listen.owner = www-data
;listen.group = www-data
;listen.mode = 0660
access.log = /proc/self/fd/2
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
; Ensure worker stdout and stderr are sent to the main error log.
catch_workers_output = yes
Problem could be in the www.conf file.
You are listening to 127.0.0.1:9000 but this way the service won't be reachable outside the container.
Try binding to 0.0.0.0:9000:
listen = 0.0.0.0:9000
This may sound very obvious, but another common issue would be that php-fpm is not installed. This can happen even though systemctl might say that the service is running but it's not really running anything. In my case, I had also installed PHP 8 with it's own fpm package, so if you have multiple php installations, there could have been a mix up with which fpm version you installed.

Can't make nginx and php-fpm dockers communicate

I have created two docker images to match my needs, here is the nginx one:
FROM alpine:3.3
RUN apk add --update nginx
EXPOSE 80 443
CMD nginx -c /www/dev/nginx/conf/nginx.conf -g 'daemon off;'
then the php-fpm
FROM php:7.0-fpm
RUN apt-get update
RUN apt-get install -y apt-transport-https ca-certificates dcmtk libgdcm-tools wkhtmltopdf libdbd-freetds libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
&& docker-php-ext-install -j$(nproc) iconv mcrypt \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd
RUN apt-get install -y imagemagick --fix-missing
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
WORKDIR /www/public
CMD rm /etc/freetds.conf
ADD freetds.conf /etc/freetds.conf
CMD rm /var/cache/apk/*
Then the run commands in the following order
docker create -p 9000:9000 --name php -v /www:/www:rw php
docker start php
docker create --privileged=true -p 80:80 -p 443:443 --name nginx -v /www:/www --link php:php nginx
docker start nginx
So far all works good, containers are running and I can even get static content from nginx owever any php script fails with
[error] 6#0: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 172.17.0.1, server: platform.v2.vetology.net, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://172.17.0.2:9000", host: "localhost.localdomain"
doing
cgi-fcgi -bind -connect 127.0.0.1:9000
from the host machine works and php responds so I know both containers ar working and responsive they just don't communicate.
I read in a different thread that the issue is caused by php and nginx using a different root directory but here is not the case as both have the /www directory mounted and /www/public contains the index.php file I am trying to open.
And here is the nginx.conf
user nobody;
error_log /www/dev/nginx/log/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
worker_processes 1;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /www/dev/nginx/log/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
include /etc/nginx/conf.d/*.conf;
default_type application/octet-stream;
gzip on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
include /www/dev/nginx/conf/upstream.conf;
server {
listen 80;
listen 443 ssl;
listen [::]:443 default ipv6only=on;
listen [::]:80 default_server ipv6only=on;
ssl_certificate /www/dev/ssl/certificate.crt;
ssl_certificate_key /www/dev/ssl/key.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
root /www/public;
index index.php index.html index.htm;
server_name hostname.net;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
client_body_buffer_size 128k;
client_body_temp_path /www/dev/nginx/tmp/client_body_temp;
proxy_temp_path /www/dev/nginx/tmp/proxy_temp_path;
fastcgi_temp_path /www/dev/nginx/tmp/fastcgi_temp_path;
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param HTTP_PROXY "";
fastcgi_pass vetology;
fastcgi_index index.php;
include fastcgi_params;
}
}
}
Any ideas of what I maybe doing wrong?
First off, I'm not sure you want to start the nginx container with privileged. There's also no need to mount the php directive with the :rw switch. rw is the default mode.
Second, take a look at where you're telling nginx to send the php request -- specifically, which host, which is defined in nginx's fastcgi_pass directive. You have it sending the php request to a machine named vetology. But docker is linking the containers together with --link php:php. That means its taking the container named php and giving it the alias named php. That means it will be exposed to your nginx container as a machine named php.
You can try this out:
docker run -it --rm --link php:some_php nginx sh -c 'ping some_php'
Change
fastcgi_pass vetology;
to:
fastcgi_pass php:9000;
And your container should work.
For complex container assemblies like this one, have a look at docker-compose next.

Categories