代码之家  ›  专栏  ›  技术社区  ›  iamabhaykmr

/bin/sh:1:无法创建/etc/nginx/nginx.conf:目录不存在命令“/bin/sh-c echo”daemon off;“>>/etc/nginx/nginx.conf'

  •  1
  • iamabhaykmr  · 技术社区  · 5 年前

    下面是相关的文件,用于为相同的文件创建docker容器

    Dockerfile 内容

    FROM python:3.6
    
    MAINTAINER Dockerfiles
    
    RUN mkdir /trell-ds-framework
    WORKDIR /trell-ds-framework
    ADD . /trell-ds-framework/
    RUN python setup.py bdist_wheel
    # install uwsgi now because it takes a little while
    RUN pip3 install uwsgi
    # copy over our requirements.txt file
    # upgrade pip and install required python packages
    RUN pip3 --no-cache-dir install -U pip
    RUN apt-get install -y ca-certificates
    RUN apt-get update && apt-get -y install cron
    RUN pip3 --no-cache-dir install -r requirements.txt
    RUN python -c "import nltk;nltk.download('stopwords')"
    # setup all the configfiles
    RUN echo "daemon off;" >> /etc/nginx/nginx.conf
    COPY nginx_app.conf /etc/nginx/sites-available/default
    COPY supervisor_app.conf /etc/supervisor/conf.d/
    
    
    # add (the rest of) our code
    
    EXPOSE 80
    CMD ["supervisord"]
    

    supervisor_app.conf

    [supervisord]
    nodaemon=true
    
    [program:uwsgi]
    command = /usr/local/bin/uwsgi --ini /trell-ds-framework/uwsgi.ini
    stdout_logfile=/dev/stdout
    stdout_logfile_maxbytes=0
    stderr_logfile=/dev/stderr
    stderr_logfile_maxbytes=0
    
    [program:nginx]
    command = /usr/sbin/nginx
    stdout_logfile=/dev/stdout
    stdout_logfile_maxbytes=0
    stderr_logfile=/dev/stderr
    stderr_logfile_maxbytes=0
    

    nginx_app.conf

    server {
        listen 80 default_server;
        server_name ip_address;
    
        # max upload size
        client_max_body_size 75M;   # adjust to taste
    
        location / {
            include uwsgi_params;
            uwsgi_pass unix:///trell-ds-framework/app.sock;
        }
    }
    

    uwsgi.ini 文件内容

    [uwsgi]
    callable = app
    chdir = /trell-ds-framework
    wsgi-file = /trell-ds-framework/wsgi.py
    socket = /trell-ds-framework/app.sock
    master = true
    processes = 2
    chmod-socket = 666
    enable-threads = true
    

    docker build -t ds_backend . ,我在Dockerfile的第13/17行遇到以下错误

    Step 13/17 : RUN echo "daemon off;" >> /etc/nginx/nginx.conf
     ---> Running in 1ee5628a4bc2
    /bin/sh: 1: cannot create /etc/nginx/nginx.conf: Directory nonexistent
    The command '/bin/sh -c echo "daemon off;" >> /etc/nginx/nginx.conf' returned a non-zero code: 2
    

    /etc/nginx/nginx.conf

    Tutorial - Deploy flask app with uwsgi/nginx using docker 这似乎起作用了。但在我看来,这是一个错误。

    在遵循注释说明之后,我可以成功地构建docker映像。现在我得到下面这个错误。

    docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"supervisord\": executable file not found in $PATH": unknown.
    

    谁能帮帮我吗。提前谢谢。

    0 回复  |  直到 5 年前
        1
  •  1
  •   Marko E    5 年前

    supervisor_app.conf

    [program:nginx]
    command = /usr/sbin/nginx -g "daemon off;"
    stdout_logfile=/dev/stdout
    stdout_logfile_maxbytes=0
    stderr_logfile=/dev/stderr
    stderr_logfile_maxbytes=0
    

    我想这是你需要的。


    apt-get install -y supervisor
    

    RUN apt-get install -y ca-certificates supervisor
    

    注意,你已经有了那条线,只是没有 supervisor .


    EDIT2:根据@thsutton的回答,你还需要添加 nginx 包裹,和你为我做的一样 .

        2
  •  1
  •   thsutton    5 年前

    python:3.6 图像已包含 nginx supervisord ? 如果没有,则由您自行安装(使用 apt-get 或类似的命令)。

    nginx配置文件不存在,二进制文件也不存在,这一事实向我暗示,也许包是不存在的