Rede do Docker - nginx: host [emerg] não encontrado no upstream

Recentemente, comecei a migrar para os recursos de rede do Docker 1.9 e Docker-Compose 1.5 para substituir o uso de links.

Até agora, com links, não havia problemas com o nginx na conexão com o meu servidor php5-fpm fastcgi localizado em um servidor diferente em um grupo via docker-compose. Recentemente, quando eu corrodocker-compose --x-networking up meus contêineres php-fpm, mongo e nginx são inicializados, no entanto, o nginx sai imediatamente com[emerg] 1#1: host not found in upstream "waapi_php_1" in /etc/nginx/conf.d/default.conf:16

No entanto, se eu executar o comando docker-compose novamente enquanto os contêineres php e mongo estiverem em execução (nginx encerrado), o nginx será iniciado e funcionará bem a partir de então.

Este é meudocker-compose.yml Arquivo:

nginx:
  image: nginx
  ports:
    - "42080:80"
  volumes:
    - ./config/docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro

php:
  build: config/docker/php
  ports:
    - "42022:22"
  volumes:
    - .:/var/www/html
  env_file: config/docker/php/.env.development

mongo:
  image: mongo
  ports:
    - "42017:27017"
  volumes:
    - /var/mongodata/wa-api:/data/db
  command: --smallfiles

Este é meudefault.conf para nginx:

server {
    listen  80;

    root /var/www/test;

    error_log /dev/stdout debug;
    access_log /dev/stdout;

    location / {
        # try to serve file directly, fallback to app.php
        try_files $uri /index.php$is_args$args;
    }

    location ~ ^/.+\.php(/|$) {
        # Referencing the php service host (Docker)
        fastcgi_pass waapi_php_1:9000;

        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;

        # We must reference the document_root of the external server ourselves here.
        fastcgi_param SCRIPT_FILENAME /var/www/html/public$fastcgi_script_name;

        fastcgi_param HTTPS off;
    }
}

Como faço para que o nginx funcione apenas com uma única chamada de docker-compose?

questionAnswers(13)

yourAnswerToTheQuestion