Deploying php-fpm+nginx fails

Hi all,

I have been trying to setup my development (LEMP) environment to deploy to a rancher server.

I am using docker-composer alongside with rancher-compose tools, using S3 bucket as decribed in “Building with AWS S3”, sorry if dont post link, I am limited as new user. I can start my stack with all containers.

From inside nginx I can ping php-fpm container. I get:

PING [php-container-name].[nginx-container-name].[stack-name].rancher.internal 

So php-fpm is visible to nginx, but in my nginx logs I get:

[error] 11#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: [IP], server: [host-name], request: "GET / HTTP/1.1", upstream: "fastcgi://0.0.0.0:9000", host: "[host-name]"

My docker-compose.yml file:

version: "2"

services:

nginx-stage:
  build: "./docker/stage/nginx/"
  container_name: "nginx-stage"
  labels:
    io.rancher.sidekicks: php-stage
  volumes:
    - /home/capistrano/project-dir/current:/var/www/html
  depends_on:
    - mysql-stage  # ignored definition to reduce post size
  links:
    - php-stage
  restart: unless-stopped
  expose:
    - "80"
php-stage:
  build: "./docker/stage/php/"
  container_name: "php-stage"
  volumes_from:
    - nginx-stage
  expose:
    - "9000"

In rancher-compose.yml I only have variable definitions. I was expecting this setup to work more or less seamless but faced problems with volumes, that’s why decided to use the sidekicks approach after reading this comment. Also because of this answer.

In general I have (except for the labels) the same setup on local development environment and it works fine. Tried to use the same for rancher with the differences mentioned. I can confirm nginx is passing correct script name to php-fpm and source code is properly mounted in expected directories (/var/www/html) in both containers. Permissions are set, user (www-data) GID are the same in host and in container.

  • If I mount code location in server as volume in both container, I get the infamous “Primary script unknown”. I receive logs entries in php and nginx that is trying to process it correctly, but php can not find scripts.

  • If I decide to use sidekicks / volumes_from approach I get the Connection refused mentioned earlier. And php container doesn’t seems to receive anything, since logs are empty.

One thing I tried to debug fpm was using cgi-fcgi -bind -connect, ran from nginx container and from php container as well, in all cases I receive:

Content-type: text/html; charset=UTF-8

as answer from fast-cgi. But when trying to access from outside I get the Connection refused, which is currently the setup used for mounting the source code. I would like to avoid building source code images or alike solutions, the same applies to build one franken-container with all dependencies inside.

If somebody can shed some light on why can not get this to work I will be highly appreciated. I don’t know what / where else to try / look for. If some more data is needed just ask.

Thanks in advance for the time and such a great tool that rancher is.
Cheers,
David