V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
chengxiao
V2EX  ›  Docker

请教下 diocker 内的 uwsgi 和 nginx 如何通信呢?

  •  
  •   chengxiao · 2018-07-23 10:28:56 +08:00 · 2754 次点击
    这是一个创建于 2348 天前的主题,其中的信息可能已经有所发展或是发生改变。

    刚初学 Docker, 有些地方不是很理解,写了一个镜像,单启用 uwsgi 的话没有问题,想请教一下, docker 内部 nginx 和 wsgi 该如何通信呢? 我是 build 镜像后 ,先 docker run -p 8010:80 image 启动 docker 和 uwsgi 然后 docker exec container_id /etc/init.d/nginx start 启动 nginx 的

    Dockerfile

    FROM ubuntu:16.04
    RUN rm -rf /etc/apt/sources.list
    COPY ./sources.list /etc/apt/sources.list(换了阿里的 ubuntu 源)
    RUN apt-get update
    RUN apt-get upgrade -y
    RUN apt-get install -y python2.7 python-dev python-pip python-setuptools git ssh ca-certificates git-core nginx
    RUN mkdir /www
    RUN mkdir /www/ini/
    RUN mkdir /www/public/
    RUN mkdir /www/log/
    RUN touch /www/log/project.log
    COPY ./requirements.txt /www/ini/requirements.txt
    COPY ./uwsgi.ini /www/ini/uwsgi.ini
    COPY ./site.conf /etc/nginx/sites-enabled/site.conf
    RUN pip install --upgrade pip
    RUN pip install -r /www/ini/requirements.txt -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
    RUN pip install uwsgi -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
    WORKDIR /www/public
    RUN git config --global user.name "my name"
    RUN git config --global user.email "my email"
    RUN git clone http://xxxxxx:xxxxxx(此处应有隐藏)@git.coding.net/chengxiao/yuqingweb.git
    EXPOSE 80
    CMD ["uwsgi", "--ini","/www/ini/uwsgi.ini"]
    
    
    

    uwsgi 配置

    # Django-related settings
    [uwsgi]
    
    socket  = /www/ini/uwsgi.sock
    
    # the base directory (full path)
    chdir           = /www/public/project/
    
    # Django s wsgi file
    module          = project.wsgi
    
    # process-related settings
    # master
    master          = true
    # maximum number of worker processes
    processes       = 6
    listen = 100
    buffer-size  = 8192
    
    # ... with appropriate permissions - may be needed
    # chmod-socket    = 664
    # clear environment on exit
    vacuum          = true
    
    

    Nginx 配置

    server {
        # the port your site will be served on
        listen      80;
        # the domain name it will serve for
        server_name localhost; # substitute your machine's IP address or FQDN
        charset     utf-8;
    
        # max upload size
        client_max_body_size 75M;   # adjust to taste
    
        # Django media
        location /media  {
            alias /www/public/project/media;
        }
        location /static {
            alias /www/public/project/static;
        }
    
       location / {
            include     uwsgi_params; 
            uwsgi_pass  unix:///www/ini/uwsgi.sock;
    
            }
    
    }
    
    
    第 1 条附言  ·  2018-07-23 13:13:08 +08:00
    找到问题了, Nginx 下 default 配置文件没有删....
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2109 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 21ms · UTC 16:13 · PVG 00:13 · LAX 08:13 · JFK 11:13
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.