![](/img/trans.png)
[英]OCI runtime create failed: container_linux.go:349: starting container process caused “exec: \”xxxx\“: executable file not found in $PATH”: unknown
[英]cannot create /etc/nginx/nginx.conf: Directory nonexistent and starting container caused “exec: \”supervisord\“: executable file not found in $PATH”
我正在构建 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 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
我检查了这个/etc/nginx/nginx.conf
文件存在于我的虚拟机中。
我正在从这个教程中获得帮助- 使用 docker 部署带有 uwsgi/nginx 的烧瓶应用程序,这似乎正在工作。 但在我的情况下,它给出了那个错误。
按照评论说明后,我可以成功构建 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
所做的一样。
python:3.6
图像是否已经包含nginx
和supervisord
? 如果没有, apt-get
您来安装它们(使用apt-get
或类似的命令,视情况而定)。
nginx 配置文件不存在且二进制文件不存在的事实向我暗示可能未安装软件包。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.