How to run Python Flask within a Docker container [duplicate]

This question already has an answer here:

  • Deploying a minimal flask app in docker – server connection issues

    2 answers

  • Docker swarm: How to specify cpu units provided by a node?
  • What is a simple workflow to use docker in Windows with a basic file sharing possibility?
  • How does device mapper “union” docker images
  • Docker - Override content of linked volume
  • Intellij, Spring dev tools remote, Docker, error Unexpected 404 response uploading class files
  • Pulling image from local docker registry: download completed, but image not found
  • Downloading images from custom registry with go-dockerclient hangs
  • Concurrent access to docker.sock on k8s
  • Dockerfile/npm: create a sudo user to run npm install
  • What is the different between putting a separate service discovery and integrate it into the cluster machine in Docker Swarm
  • Is there any way to pull an image from private registry and cut URL?
  • Docker: some ghost images are messing up with the memory
  • One Solution collect form web for “How to run Python Flask within a Docker container [duplicate]”

    Try app.run(host='0.0.0.0').

    By default, Flask server is only accessible from the localhost. In your case, the container is the localhost, and your requests are originating from outside the container. host='0.0.0.0' parameter makes the server accessible from external IPs. It’s described in Flask documentation in detail.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.