I'm having an issue with my containers communicating to each other. The linking of the containers is working but the php-fpm process isn't working.

php container =
nginx container =
This is my nginx config for the only site running on the nginx container.

upstream phpcgi {

server php:9000;

server {
    listen 80 ;

    root /srv/www;
    index index.html index.htm index.php;

    server_name localhost;

    location / {
            try_files $uri $uri/ =404;


    location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

            # With php5-cgi alone:
            fastcgi_pass phpcgi;

            # With php5-fpm:
            fastcgi_index index.php;
            fastcgi_param  QUERY_STRING       $query_string;
            fastcgi_param  REQUEST_METHOD     $request_method;
            fastcgi_param  CONTENT_TYPE       $content_type;
            fastcgi_param  CONTENT_LENGTH     $content_length;

            fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
            fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
            fastcgi_param  REQUEST_URI        $request_uri;
            fastcgi_param  DOCUMENT_URI       $document_uri;
            fastcgi_param  DOCUMENT_ROOT      $document_root;
            fastcgi_param  SERVER_PROTOCOL    $server_protocol;

            fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
            fastcgi_param  SERVER_SOFTWARE    nginx;

            fastcgi_param  REMOTE_ADDR        $remote_addr;
            fastcgi_param  REMOTE_PORT        $remote_port;
            fastcgi_param  SERVER_ADDR        $server_addr;
            fastcgi_param  SERVER_PORT        $server_port;
            fastcgi_param  SERVER_NAME        $server_name;
            #include fastcgi_params;


This is my www.conf in my php-fpm/fpm/pool.d within my php container

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific address on
;                            a specific port;
;   'port'                 - to listen on a TCP socket to all addresses on a
;                            specific port;
;   '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen =

; Set listen(2) backlog.
; Default Value: 65535 (-1 on FreeBSD and OpenBSD)
;listen.backlog = 65535

; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
;                 mode is set to 0660
listen.owner = www-data
listen.group = www-data
;listen.mode = 0660

; List of ipv4 addresses of FastCGI clients which are allowed to connect.
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
; must be separated by a comma. If this value is left blank, connections will be
; accepted from any ip address.
; Default Value: any
;listen.allowed_clients =

The two containers are able to ping each other but i get an error in the nginx log, as follows.

[error] 27#0: *1 FastCGI sent in stderr: "Primary script unknown" while reading response headerf rom upstream, client: xxx.xxx.xxx.xxx, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://", host: "xxx.xxx.xxx.xxx:49234"

the IP of the last computer is of the server running docker.

What am I doing wrong?

  • Is /srv/www attached to both containers? – Michael Hampton Oct 6 '14 at 21:11
  • only the nginx container has /srv/www with files in it. I thought that the nginx server would relay the files to the php5-fpm process similar to a proxy_pass. Isn't that how a php5-fpm cluster would work? Does the working web directory need to replicated on every instance php is running? – user55409 Oct 6 '14 at 21:14
  • 2
    Then that's why it doesn't work. PHP needs to be able to read the files! – Michael Hampton Oct 6 '14 at 21:15
  • so if I wanted a php-fpm cluster and have multiple servers define in the upstream phpcgi section, I would need to replicate each working directory? – user55409 Oct 6 '14 at 21:24
  • 1
    Yes, every PHP-FPM instance needs to be able to access the script files. – Tero Kilkanen Oct 7 '14 at 11:22

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.