【问题标题】:Dockerized Nginx upstream error serving separate Docker container with Flask/uWSGI appDockerized Nginx 上游错误使用 Flask/uWSGI 应用程序为单独的 Docker 容器提供服务
【发布时间】:2015-12-05 16:31:59
【问题描述】:

在运行 docker-compose build && docker-compose up 并尝试访问我的索引页面后,我的多容器 Docker 设置遇到以下错误:

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

这是我的 docker-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/sample-nginx.conf

upstream flask {
    server web:8000;
}

server {

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

    location / {
        uwsgi_pass flask;
        include uwsgi_params;
    }
}

网络应用/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-app/sample-uswgi.ini

[uwsgi]

module = application
callable = app

master = true
processes = 5

socket = web:8000

chown-socket = www-data:www-data

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

请不要发布有关单个容器设置的建议。我正在做一个练习,以便能够扩展在单个 nginx 容器下提供的 Docker 应用程序容器。

【问题讨论】:

    标签: nginx docker uwsgi


    【解决方案1】:

    秘诀正在将 sample-uwsgi.ini 中的套接字行更改为:

    socket = 0.0.0.0:8000
    

    【讨论】:

      猜你喜欢
      • 2017-11-15
      • 2014-03-08
      • 2017-03-08
      • 2021-04-28
      • 1970-01-01
      • 2017-06-14
      • 2020-07-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多