简体   繁体   English

无法创建 /etc/nginx/nginx.conf: 目录不存在并且启动容器导致“exec:\\”supervisord\\“:executable file not found in $PATH”

[英]cannot create /etc/nginx/nginx.conf: Directory nonexistent and starting container caused “exec: \”supervisord\“: executable file not found in $PATH”

I am building docker image to deploy flask app with uwsgi/nginx.我正在构建 docker 镜像以使用 uwsgi/nginx 部署 Flask 应用程序。

Here are relevant file for to create a docker container for same这里有相关文件用于创建相同的 docker 容器

Dockerfile content 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 content 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 content 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 file content 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

when I am trying to build the docker image in trell-ds-framework directory (using command docker build -t ds_backend . , I am getting following error on line 13/17 of Dockerfile当我尝试在 trell-ds-framework 目录中docker build -t ds_backend . (使用命令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

I checked this /etc/nginx/nginx.conf file exists in my virtual machine.我检查了这个/etc/nginx/nginx.conf文件存在于我的虚拟机中。

I am taking help from this Tutorial - Deploy flask app with uwsgi/nginx using docker which seems to be working.我正在从这个教程中获得帮助- 使用 docker 部署带有 uwsgi/nginx 的烧瓶应用程序,这似乎正在工作。 But in my case its giving that error.但在我的情况下,它给出了那个错误。

After following comments instruction I could build docker image successfully.按照评论说明后,我可以成功构建 docker 镜像。 Now I am getting this error below.现在我在下面收到此错误。

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.

Can anybody help me out here.任何人都可以在这里帮助我。 Thanks in advance.提前致谢。

PS: I am very new to these things. PS:我对这些东西很陌生。 Any leads highly appreciated.任何线索高度赞赏。

Since managing answers with comments is nearly impossible, I'll post the outlook of the supervisor_app.conf file here:由于管理带有评论的答案几乎是不可能的,我将在这里发布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

I think it's what you need.我认为这就是你所需要的。


EDIT: I just saw the comment about supervisor not being found.编辑:我刚刚看到有关找不到主管的评论。 It seems that you haven't installed it in Dockerfile.看来你还没有在Dockerfile中安装它。 Here's how to add it:添加方法如下:

apt-get install -y supervisor

You can add just the package name in one of the steps, like this:您可以在其中一个步骤中只添加包名称,如下所示:

RUN apt-get install -y ca-certificates supervisor

Note that you already have that line, just without supervisor .请注意,您已经有了该行,只是没有supervisor


EDIT2: As per @thsutton's answer, you also need to add nginx package, the same way you did for supervisor . EDIT2:根据@thsutton 的回答,您还需要添加nginx包,就像您为supervisor所做的一样。

Does the python:3.6 image already contain nginx and supervisord ? python:3.6图像是否已经包含nginxsupervisord If not, it is up to you to install them (with apt-get or a similar command, as appropriate).如果没有, apt-get您来安装它们(使用apt-get或类似的命令,视情况而定)。

The fact that the nginx config file doesn't exist, and the binary doesn't exist would suggest to me that maybe the packages are not installed. nginx 配置文件不存在且二进制文件不存在的事实向我暗示可能安装软件包。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 OCI 运行时创建失败:container_linux.go:349:启动容器进程导致“exec:\\”xxxx\\“:在 $PATH 中找不到可执行文件”:未知 - OCI runtime create failed: container_linux.go:349: starting container process caused “exec: \”xxxx\“: executable file not found in $PATH”: unknown OCI 运行时创建失败:container_linux.go:348:启动容器进程导致“exec:\\”-it\\“:在 $PATH 中找不到可执行文件”:未知 - OCI runtime create failed: container_linux.go:348: starting container process caused “exec: \”-it\“: executable file not found in $PATH”:unknown Docker:OCI 运行时创建失败:container_linux.go:349:启动容器进程导致“exec:\”java\“:$PATH 中找不到可执行文件” - Docker: OCI runtime create failed: container_linux.go:349: starting container process caused “exec: \”java\“: executable file not found in $PATH” 启动容器进程导致“exec: > \\”exec\\”:在 $PATH 中找不到可执行文件”:未知 - starting container process caused "exec: > \"exec\": executable file not found in $PATH": unknown container_linux.go:349: 启动容器进程导致 exec: flask: 在 $PATH 中找不到可执行文件 - container_linux.go:349: starting container process caused exec: flask: executable file not found in $PATH 运行 docker 容器时出错:启动容器进程导致“exec:\”python\“:在 $PATH 中找不到可执行文件”:未知 - Error running docker container: starting container process caused "exec: \"python\": executable file not found in $PATH": unknown 如何解决 docker OCI 运行时创建失败的启动容器进程导致“exec:\”java\“:$PATH 中找不到可执行文件”: - How to solve docker OCI runtime create failed starting container process caused “exec: \”java\“: executable file not found in $PATH”: nginx:在 /etc/nginx/conf.d/nginx.conf:12 的上游“php”中找不到 [emerg] 主机 - nginx: [emerg] host not found in upstream "php" in /etc/nginx/conf.d/nginx.conf:12 启动容器进程导致 "exec: \\"uwsgi\\": executable file not found in $PATH": unknown - starting container process caused "exec: \"uwsgi\": executable file not found in $PATH": unknown 启动容器进程导致:exec:“powershell”:$PATH 中找不到可执行文件:未知 - Starting container process caused: exec: “powershell”: executable file not found in $PATH: unknown
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM