Deploying a minimal flask app in docker - server connection issues

后端 未结 6 1373
清酒与你
清酒与你 2020-11-22 00:51

I have an app who\'s only dependency is flask, which runs fine outside docker and binds to the default port 5000. Here is the full source:

from          


        
6条回答
  •  醉梦人生
    2020-11-22 01:18

    First of all in your python script you need to change code from

    app.run()
    

    to

    app.run(host="0.0.0.0")
    

    Second, In your docker file, last line should be like

    CMD ["flask", "run", "-h", "0.0.0.0", "-p", "5000"]
    

    And on host machine if 0.0.0.0:5000 doesn't work then you should try with localhost:5000

    Note - The CMD command has to be proper. Because CMD command provide defaults for executing container.

提交回复
热议问题