我的烧瓶应用程序,在端口5000上启动烧瓶服务器的主文件位于:
服务器/main/core/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"
我的错误在Dockerfile中:
我将setup.py
的默认路径从Server/setup.py
更改为Server/app/main/core/setup.py
询问如何在此路径上启动服务器
# 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"]
答案 0 :(得分:2)
入口点(https://docs.docker.com/engine/reference/builder/#entrypoint)和workdir(https://docs.docker.com/engine/reference/builder/#workdir)有点混乱 请记住,您可以多次使用WORKDIR。
你的setup.py应该在路径中:
Server/main/core/setup.py
我想你的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"]