[英]Trying to run a docker server
folks i have a web folder which has the following files inside: app.py Docker file requirements.txt outside that file i have a docker-compose.yml伙计们,我有一个 web 文件夹,其中包含以下文件:app.py Docker 文件 requirements.txt 在该文件之外我有一个 docker-compose.yml
the code is as follows: app.py代码如下:app.py
code...
if __name__ == "__main__":
app.run(host='0.0.0.0')
on the requirements txt:关于要求txt:
Flask
flask_restful
on the DockerFile:在 DockerFile 上:
FROM python:3
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD [ "python", "./app.py" ]
and on the docker-compose.yml:在 docker-compose.yml 上:
version: '3'
services:
web:
build: ./web
ports:
- "5000:5000"
i go on the terminal and i run docker compose build and docker compose up我在终端上运行 go 并运行 docker 组合构建和 docker 组合
and server runs as below:和服务器运行如下:
se 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
PS C:\Users\sarandis\Desktop\Python API\web service> docker compose up
webservice-web-1 | * Serving Flask app 'app' (lazy loading)
webservice-web-1 | * Environment: production 0.6s
webservice-web-1 | WARNING: This is a development server.
Do not use it in a production deployment.
webservice-web-1 | Use a production WSGI server instead.
webservice-web-1 | * Debug mode: off Do not use it in a production deployment.
webservice-web-1 | * Running on all addresses.
webservice-web-1 | WARNING: This is a development server.
Do not use it in a production deployment.
webservice-web-1 | * Running on http://172.18.0.2:5000/ (PreDo not use it in a production deployment.ss CTRL+C to quit) ss CTRL+C to quit)
Gracefully stopping...
the problem i have when i click on the url it provides me it says that the site cant be reached??当我点击 url 时我遇到的问题它提供给我它说该网站无法访问? why is that?这是为什么? what em i doing wrong?我做错了什么?
note that when i do flask run the app runs at it should and all the get and post requests work fine!请注意,当我运行 flask 运行应用程序时,它应该运行并且所有获取和发布请求都可以正常工作!
Thank you in advance先感谢您
Have you tried to access http://localhost:5000 instead of the provided URL?您是否尝试访问 http://localhost:5000 而不是提供的 URL?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.