[英]Docker. How to run a flask server main file that start the server inside deeper file structure
My flask app, the main file that starts the flask server on port 5000 is inside: 我的flask应用程序(在端口5000上启动flask服务器的主文件)位于内部:
Server /main/core/setup.py
服务器/main/core/setup.py
The Docker gives me this error and I know because it cannot find the setup.py
: Docker给了我这个错误,我知道是因为它找不到setup.py
:
ERROR: for flask_api Cannot start service flask_api: oci runtime error:
container_linux.go:265: starting container process caused "exec:
\"/main/api/core\": stat /main/api/core: no such file or directory"
My error is inside the Dockerfile: 我的错误是在Dockerfile内部:
I change my default path of the setup.py
from the Server/setup.py
to Server/app/main/core/setup.py
我将setup.py
默认路径从Server/setup.py
更改为Server/app/main/core/setup.py
Question how to start the server on this path 质疑如何在此路径上启动服务器
# FROM python:3.6-alpine
# ADD ./Server /app
# WORKDIR /app
# RUN pip install -r requirements.txt
# EXPOSE 5000
# CMD ["python", "api.py"]
FROM python:3.6-alpine
ADD ./Server /app
WORKDIR /app
RUN pip install -r requirements.txt
EXPOSE 5000
ENTRYPOINT ["/main/core"]
CMD ["python", "setup.py"]
There is a little mess with entrypoint ( https://docs.docker.com/engine/reference/builder/#entrypoint ) and workdir ( https://docs.docker.com/engine/reference/builder/#workdir ) Please remember that you can use WORKDIR multiple times. 入口点( https://docs.docker.com/engine/reference/builder/#entrypoint )和工作目录( https://docs.docker.com/engine/reference/builder/#workdir )有点混乱请记住,您可以多次使用WORKDIR。
Your setup.py should be in path: 您的setup.py应该在路径中:
Server/main/core/setup.py
I suppose that your Dockerfile should be: 我想你的Dockerfile应该是:
FROM python:3.6-alpine
ADD ./Server /app
WORKDIR /app
RUN pip install -r requirements.txt
EXPOSE 5000
WORKDIR /app/main/core
CMD ["python", "setup.py"]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.