运行docker容器时出错:导致启动容器进程“ exec:\” python\”:在$ PATH中找不到可执行文件”:未知 [英] Error running docker container: starting container process caused "exec: \"python\": executable file not found in $PATH": unknown
问题描述
我正在尝试对一个简单的Python-Flask应用程序进行Docker化,但是在运行容器时出现错误。
I am trying to dockerize a simple Python-Flask application but I am getting an error while running my container.
docker:守护程序的错误响应:OCI运行时创建失败:container_linux.go:344:启动容器进程导致 exec:\ python\:在$ PATH中找不到可执行文件:未知。
docker: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: \"python\": executable file not found in $PATH": unknown.
Workdir在本地主机上:
Workdir on localhost:
/home/ubuntu/flask_web
- app.py
- Dockerfile
- requirements.txt
app.py
#flask_web/app.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hey, we have Flask in a Docker container'
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')
Dockerfile
Dockerfile
FROM ubuntu:16.04
MAINTAINER xyz "xyz@gmail.com"
RUN apt-get update \
&& apt-get install -y software-properties-common vim \
&& add-apt-repository ppa:jonathonf/python-3.6 \
&& apt-get update -y \
&& apt-get install -y build-essential python3.6 python3.6-dev python3-pip python3.6-venv \
&& pip3 install --upgrade pip
# We copy just the requirements.txt first to leverage Docker cache
COPY ./requirements.txt /app/requirements.txt
WORKDIR /app
RUN pip install -r requirements.txt
COPY . /app
ENTRYPOINT [ "python" ]
CMD [ "app.py" ]
命令:
docker build -t flask-test:latest .
docker run -p 5000:5000 flask-test
预期:Flask web应该在端口5000
Expected : Flask web should run on port 5000
实际结果:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: \"python\": executable file not found in $PATH": unknown.
推荐答案
没有 / usr / bin / python
在由以上代码构建的docker映像中。但是有 / usr / bin / python3
。因此,您可以直接将 python3
用作 ENTRYPOINT
或创建符号链接。
There is no /usr/bin/python
in a docker image built by the code above. But there is /usr/bin/python3
. So you could either use python3
directly as your ENTRYPOINT
or create a symlink.
这篇关于运行docker容器时出错:导致启动容器进程“ exec:\” python\”:在$ PATH中找不到可执行文件”:未知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!