Deploying a minimal flask app in docker - server connection issues

后端 未结 6 1285
清酒与你
清酒与你 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:30

    The problem is you are only binding to the localhost interface, you should be binding to 0.0.0.0 if you want the container to be accessible from outside. If you change:

    if __name__ == '__main__':
        app.run()
    

    to

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

    It should work.

提交回复
热议问题