簡體   English   中英

嘗試運行 docker 服務器

[英]Trying to run a docker server

伙計們,我有一個 web 文件夾,其中包含以下文件:app.py Docker 文件 requirements.txt 在該文件之外我有一個 docker-compose.yml

代碼如下:app.py

code...

if __name__ == "__main__":
  app.run(host='0.0.0.0')

關於要求txt:

Flask
flask_restful

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

在 docker-compose.yml 上:

version: '3'

services:
  web: 
    build: ./web
    ports:
      - "5000:5000"

我在終端上運行 go 並運行 docker 組合構建和 docker 組合

和服務器運行如下:

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... 

當我點擊 url 時我遇到的問題它提供給我它說該網站無法訪問? 這是為什么? 我做錯了什么?

請注意,當我運行 flask 運行應用程序時,它應該運行並且所有獲取和發布請求都可以正常工作!

先感謝您

您是否嘗試訪問 http://localhost:5000 而不是提供的 URL?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM