[英]Docker run Error: /bin/sh: 1: python: not found
So, im trying to learn docker and tried making a simple image to try it out.所以,我正在尝试学习 docker 并尝试制作一个简单的图像来试用它。 The docker build part goes well but when I docker run, I get a problem:
docker 构建部分进行得很顺利,但是当我 docker run 时,我遇到了一个问题:
(base) daniellombardi@Daniels-MacBook-Pro MyApp-test % docker run bd
/bin/sh: 1: python: not found
The Dockerfile: Dockerfile:
FROM ubuntu
RUN apt-get update && apt-get install -y python3 python3-pip
RUN pip3 install flask
RUN mkdir /MyApp-test
ADD folder /opt/MyApp-test
EXPOSE 5000
CMD python .main.py
and for anyone wondering, this is the code on main.py对于任何想知道的人,这是 main.py 上的代码
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return 'IT WORKED! I AM RUNNING FROM A DOCKER CONTAINER!!!'
if __name__ == '__main__':
app.run(host="0.0.0.0", port=5000)
Since you are only install python3
inside the docker image as shown here由于您只在 docker 镜像中安装了
python3
,如下所示
RUN apt-get update && apt-get install -y python3 python3-pip
So you will need to run python3
instead of python
in this line: CMD python .main.py
所以你需要在这一行中运行
python3
而不是python
: CMD python .main.py
And you have a typo in the script name.并且您在脚本名称中有一个错字。 It should be
main.py
instead of .main.py
.它应该是
main.py
而不是.main.py
。 Or it should be ./main.py
或者它应该是
./main.py
So change it to CMD python3 ./main.py
所以改成
CMD python3 ./main.py
And if you still have error, you probably need to add this line in the Dockerfile
above line of EXPOSE 5000
:如果你仍然有错误,你可能需要在
Dockerfile
上面的EXPOSE 5000
行中添加这一行:
WORKDIR /opt/MyApp-test
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.