2015-09-03 56 views
3

我遇到了運行後,我的多容器泊塢窗設置以下錯誤泊塢窗 - 撰寫建& &泊塢窗,撰寫並試圖打我的索引頁:Docker容器經歷插座問題(單獨瓶+ Nginx的容器)

[crit] 8#8: *1 connect() to unix:/tmp/uwsgi.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.99.1, server: localhost, request: "GET/HTTP/1.1", upstream: "uwsgi://unix:/tmp/uwsgi.sock:", host: "192.168.99.100" 

這裏是我的搬運工,compose.yml:

web: 
    restart: always 
    build: ./web-app 
    expose: 
    - "8000" 
    command: /usr/local/bin/uwsgi --ini sample-uwsgi.ini 

nginx: 
    restart: always 
    build: ./nginx/ 
    ports: 
    - "80:80" 
    links: 
    - web:web 

的nginx/Dockerfile

FROM nginx 
RUN rm /etc/nginx/conf.d/default.conf 
ADD sample-nginx.conf /etc/nginx/conf.d/ 

nginx的/採樣nginx.conf

server { 

    listen 80; 
    server_name localhost; 
    charset utf-8; 
    client_max_body_size 75M; 

    location/{ 
     include uwsgi_params; 
     uwsgi_pass unix:/tmp/uwsgi.sock; 
    } 
} 

web的應用程序/ Dockerfile

FROM ansible/ubuntu14.04-ansible:stable 

WORKDIR /root 
ADD application.py application.py 
ADD requirements.txt requirements.txt 
ADD sample-uwsgi.ini sample-uwsgi.ini 

ADD ansible /srv/ansible 
WORKDIR /srv/ansible 

RUN ansible-playbook container-bootstrap.yml -c local 

web的應用程序/採樣uswgi.ini

[uwsgi] 

module = application 
callable = app 

master = true 
processes = 5 

socket = /tmp/uwsgi.sock 

chown-socket = www-data:www-data 

vacuum = true 
enable-threads=True 
die-on-term = true 

UPDATE

在廣告上從@kryten我將使用TCP/IP副

更新nginx.conf:

server { 

    listen 80; 
    server_name localhost; 
    charset utf-8; 
    client_max_body_size 75M; 

    location/{ 
     uwsgi_pass localhost:8000; 
     include uwsgi_params; 
    } 
} 

更新uwsgi.ini:

[uwsgi] 

module = application 
callable = app 

master = true 
processes = 5 

socket = localhost:8000 

chown-socket = www-data:www-data 

vacuum = true 
enable-threads=True 
die-on-term = true 

,我現在追求以下錯誤:

[error] 8#8: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.99.1, server: localhost, request: "GET/HTTP/1.1", upstream: "uwsgi://127.0.0.1:8000", host: "192.168.99.100" 

回答

5

它看起來像你的應用程序正在試圖通過Unix socket,而不是通過TCP/IP連接。

這不會來自不同容器的工作,因爲在一個容器(其中插座住)文件系統是不是在其他容器中進行訪問。

解決的辦法是重新配置你的應用程序通過TCP/IP而不是Unix套接字連接。

可能有可能通過在插座駐留到其他容器中的文件系統暴露的位置進行連接,但我從來沒有試過這種&不知道是否會工作。

+0

我已經根據你的建議進行了修改,現在打張貼在 – Erik

6

web由於和nginx是分開的容器,nginx的需要連接到另一個計算機通過TCP。 Linking the containers已經完成了大部分工作,您只需將上游指向web:8000而不是本地主機。

+0

謝謝更新一個新的nginx的問題!就是這樣。 – jrc