gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 18:58:13 25 4
gpt4 key购买 nike

我正在构建docker镜像以使用uwsgi / nginx部署Flask应用程序。
这是用于为同一容器创建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
当我尝试在trell-ds-framework目录中构建docker镜像时(使用 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.
有人可以帮我吗?提前致谢。
PS:我对这些事情很陌生。任何潜在客户高度赞赏。

最佳答案

由于用评论管理答案几乎是不可能的,因此我将在此处发布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
我认为这就是您所需要的。

编辑:我只是看到有关找不到主管的评论。似乎您尚未将其安装在Dockerfile中。新增方法如下:
apt-get install -y supervisor
您可以在以下步骤之一中仅添加包名称,如下所示:
RUN apt-get install -y ca-certificates supervisor
请注意,您已经有了该行,只是没有 supervisor

EDIT2:按照@thsutton的回答,您还需要添加 nginx包,就像对 supervisor所做的一样。

关于docker - 无法创建/etc/nginx/nginx.conf:目录不存在且启动容器导致 “exec:\”受监督的\“: executable file not found in $PATH”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63599851/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com