Run python website on docker

I have created a Python + Flask website on docker. If I do “docker-compose up” the website is available on 0.0.0.0:5000.

I have tagged and pushed the container to docker and I tried doing docker run mydomain/mycontainer from a different computer. It starts downloading everything, but at the end it displays Status: Downloaded newer image for mydomain/mycontainer:latest and nothing happens.

  • How do I create docker image from an existing CentOS?
  • How do I configure which DNS server docker uses in Docker for Mac?
  • Connection refused error with cassandra and docker-py
  • How do I build docker images when my development environment mounts my codebase into the container?
  • Failed to create the host-only adapter - windows 10, docker, virtualbox
  • Replace Docker container with external service
  • I tried doing docker run mydomain/mycontainer python app.py and it displays “Running on http://0.0.0.0:5000” but if I open that URL I get “This website is not available”. I cannot see any processes running on port 5000 either.

    Any ideas?

  • Access to the docker machine from Android app
  • Angular 2 build once, deploy anywhere
  • How does Vagrant automatically install Docker on CentOS?
  • rawmemchr: symbol not found in nodegit with docker
  • Why Docker containers can't communicate with each other?
  • Rails assets fingerprints differ on server
  • 2 Solutions collect form web for “Run python website on docker”

    The ip 0.0.0.0 is the local address inside the docker image. If you want to access it outside the image (ie. locally on your computer), you have to expose the given port. Here is the EXPOSE parameter documentation.

    If you run the command:

    docker run -p 5000:5000 mydomain/mycontainer python app.py
    

    Your server will be accessible on:

    http://localhost:5000

    BTW, I made a public (and open source) Docker image with all the bells and whistles that you can use to build a Python Flask web application.

    It has uWSGI for running the application, Nginx to serve HTTP and Supervisord to control them, so you don’t have to learn how to install and configure all those to build your Python Flask web app.

    It seems like uWSGI with Nginx is one of the more robust (and with great performance) ways to deploy a Python web app. Here are the benchmarks: http://nichol.as/benchmark-of-python-web-servers.

    There are even some template projects you can use to bootstrap your own. And also, you don’t have to clone the full project or something, you can just use it as a base image.

    Docker Hub: https://hub.docker.com/r/tiangolo/uwsgi-nginx-flask/

    GitHub: https://github.com/tiangolo/uwsgi-nginx-flask-docker

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