Gunicorn is stuck on docker run command with a Flask Application

I have my container app_container built, exposing port 8000 as per my application code. The entry point to the container is ENTRYPOINT ["/usr/local/bin/gunicorn", "web_interface:app", "-w 4", "-t 90", "--log-level=info", "-b 127.0.0.1:8000", "--reload"].

When I build and run the container with docker run --link postgres_db_container --name foo app_container, it runs the gunicorn command to the app. Unlike when i run the app locally, it stops at

  • Accessing rabbitmq running on local machine from docker container
  • Store Docker image files in external drive in El Capitan OSX
  • Deploying with docker push is slow because there are many images
  • plugin/docker : Is passing id_rsa priv key using build_args correct?
  • MessageListenerContainer not listening after crashing master redis instance in redis sentinel in docker env
  • Vagrant + Docker + Postgresql - Cannot connect from host
  • [2017-06-19 16:01:16 +0000] [1] [INFO] Starting gunicorn 19.7.1
    [2017-06-19 16:01:16 +0000] [1] [INFO] Listening at: http://127.0.0.1:8000
    [2017-06-19 16:01:16 +0000] [1] [INFO] Using worker: sync
    [2017-06-19 16:01:16 +0000] [8] [INFO] Booting worker with pid: 8
    [2017-06-19 16:01:16 +0000] [10] [INFO] Booting worker with pid: 10
    [2017-06-19 16:01:16 +0000] [11] [INFO] Booting worker with pid: 11
    [2017-06-19 16:01:16 +0000] [13] [INFO] Booting worker with pid: 13
    

    Anybody have a clue as to why the gunicorn process just stalls here, and does not continue?

    No errors to go on either. So if you have any idea how to get more info, Im all ears…

    Edit:

    When cancel the process with control+c, I see a test print message :

    ^C[2017-06-19 16:09:27 +0000] [1] [INFO] Handling signal: int
    [2017-06-19 16:09:27 +0000] [10] [INFO] Worker exiting (pid: 10)
    [2017-06-19 16:09:27 +0000] [11] [INFO] Worker exiting (pid: 11)
    [2017-06-19 16:09:27 +0000] [8] [INFO] Worker exiting (pid: 8)
    ---- Generate Mapping ----
    ---- Preparing Databases ----
    

    So it seems gunicorn is hung up on some process, but I dont know how to find out what it is.

  • Docker Mac, containers unable to VPN servers
  • Vagrant start docker image on existing machine
  • Connection refused in Docker containers communicating through exposed ports
  • how to connect to localhost:9092 from docker container using docker-compose and not using docker bridge
  • Cannot authenticate to Docker in Elastic Beanstalk through S3
  • Can I connect directly to a docker swarm network?
  • One Solution collect form web for “Gunicorn is stuck on docker run command with a Flask Application”

    Let’s give some combo suggestions:

    • Check that you are mapping a port to your localhost in order to access the container app:

      docker run -p 8000:8000 (rest of the command)
      
    • Listen to "-b 0.0.0.0:8000" instead of "-b 127.0.0.1:8000", that is a requirement for docker to map ports. So see docker ps, search for the symbol -> in PORTS column (you should see 0.0.0.0:8000->8000.

    Then, navigate to localhost:8000 in your web browser to check that your app properly renders.

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