2017-05-31 80 views
2

此作曲家文件用於工作到一週前(沒有更改)。我通過將dns: 8.8.8.8添加到docker-compose.yml文件中,再次在家中工作。Docker:在上游應用程序中找不到主機:9000

這讓我相信這個問題是與DNS相關的。

現在試圖在不同的機器(工作)上運行,但出現以下錯誤: nginx: [emerg] host not found in upstream "app:9000" in /etc/nginx/sites-enabled/default.conf:2

我不知道這意味着什麼。這是我的nginx的conf:

server { 
    listen 80; 
    listen 443 ssl http2; 

    # Server name being used (exact name, wildcards or regular expression) 
    server_name localhost; 
    client_max_body_size 200M; 

    # Document root, make sure this points to your Phalcon web directory 
    root /var/www/html/public; 
    index index.php index.html; 

    location/{ 
     try_files $uri $uri/ /index.php?_url=$uri&$args; 
    } 

    location ~ \.php$ { 
     fastcgi_pass app:9000; 
     # regex to split $uri to $fastcgi_script_name and $fastcgi_path 
     fastcgi_split_path_info ^(.+\.php)(/.+)$; 
     fastcgi_index index.php; 

     include fastcgi_params; 

     # Bypass the fact that try_files resets $fastcgi_path_info 
     # see: http://trac.nginx.org/nginx/ticket/321 
     set $path_info $fastcgi_path_info; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     fastcgi_param APPLICATION_ENV development; 

     #add_header Authorization $http_authorization; 
    } 

    # Logging 
    error_log /var/log/nginx/error.log; 
    access_log /var/log/nginx/access.log; 
} 

我的搬運工,compose.yml文件:

db: 
    image: mysql:latest 
    container_name: dev_db 
    expose: 
    - "3306" 
    ports: 
    - "3307:3306" 
    environment: 
    MYSQL_DATABASE: dbname 
    MYSQL_USER: person 
    MYSQL_PASSWORD: secret 
    MYSQL_ROOT_PASSWORD: secret 
app: 
    image: linxlad/php7-fpm 
    container_name: dev_app 
    tty: true 
    ports: 
    - "6900:6900" 
    volumes: 
    - ./logs/php-fpm:/var/log/php-fpm 
    - ..:/var/www/html 
    links: 
    - db 
web: 
    tty: true 
    image: linxlad/nginx 
    container_name: dev_web 
    ports: 
    - "8080:80" 
    volumes: 
    - ./conf/nginx:/etc/nginx/conf.d 
    - ./logs/nginx:/var/log/nginx 
    - ..:/var/www/html 
    links: 
    - app 

回購爲here

任何人都知道如何解決這個問題?

謝謝

+1

您在應用部分的映射端口6900,應該不是很9000? – Emer

+0

@Emer我試圖改變它9000:9000(用作6900:6900),停止並刪除容器,但仍然是相同的錯誤:/ – Kal

回答

4

您的nginx容器可能在您的應用程序之前啓動。你應該添加一個depends_on部分泊塢窗,compose.yml文件,告訴搬運工何種順序容器應開始

https://docs.docker.com/compose/compose-file/#depends_on

web: 
    tty: true 
    image: linxlad/nginx 
    container_name: dev_web 
    ports: 
    - "8080:80" 
    volumes: 
    - ./conf/nginx:/etc/nginx/conf.d 
    - ./logs/nginx:/var/log/nginx 
    - ..:/var/www/html 
    links: 
    - app 
    depends_on: 
    - app 
+0

工作,謝謝:)注:如果我想'版本:「3 「'我在文檔中閱讀'版本3不再支持depends_on.'的條件形式。在這種情況下我需要做什麼? – Kal

+1

我從來沒有使用'condition'形式,所以我不知道。很高興這工作,但!這是我以前遇到過的,所以我希望這對你會很簡單:) –

相關問題