简体   繁体   English

泊坞窗。 如何运行烧瓶服务器主文件,以在更深的文件结构中启动服务器

[英]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 质疑如何在此路径上启动服务器

Dockerfile: Dockerfile:

This is before I move the setup.py file that starts the server on port 5000 这是在我移动在端口5000上启动服务器的setup.py文件之前

# FROM python:3.6-alpine
# ADD ./Server /app
# WORKDIR /app
# RUN pip install -r requirements.txt
# EXPOSE 5000
# CMD ["python", "api.py"]

This is after I move the file deeper 这是我将文件更深地移动之后

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"]

Any help how to hit the setup.py ?? 任何帮助如何打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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM