Gunicorn stuck on docker when run is executed with flask application

0 votes

I'm running a container app_container built, exposing port 8000 and with its entry point being ENTRYPOINT ["/usr/local/bin/gunicorn", "web_interface:app", "-w 4", "-t 90", "--log-level=info", "-b 127.0.0.1:8000", "--reload"].

My container stops if I try and run the app locally but  if I run it with docker run --link postgres_db_container --name foo app_container, the gunicorn command runs to the app.

Locally the container stops here:

[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

If I interrupt the process it shows 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 ----

I think Gunicorn is stuck on some process.

Am I doing anything wrong here? There isn't even any error for me to troubleshoot them.

Jun 14, 2018 in DevOps Tools by DragonLord999
• 8,450 points
6,102 views
Hi,

Im facing the exact same issue. Were you able to resolve it?

Thanks.
Did you try the below-given solution?

Yes I did, but same issue. I dont think it is the port mapping issue.

When I run my docker container, its boots up and gets stuck at:

[2020-07-09 11:07:45 +0000] [1] [INFO] Starting gunicorn 19.10.0

[2020-07-09 11:07:45 +0000] [1] [INFO] Listening at: http://0.0.0.0:5002 (1)

[2020-07-09 11:07:45 +0000] [1] [INFO] Using worker: sync

[2020-07-09 11:07:45 +0000] [8] [INFO] Booting worker with pid: 8

This is the same even if I increase timeout.
But once I enter Ctrl+C to exit, it prints the output

^C[2020-07-09 11:08:51 +0000] [1] [INFO] Handling signal: int
checkpoint1
checkpoint2
checkpoint3
checkpoint4

Port mapping are also correct.
Why is this happening? I even tried with different versions of gunicorn and python. But still the same.My docker cmd:

CMD ["gunicorn","-w","1","--timeout","1200","-b","0.0.0.0:5002","api:app"]

Try with detach mode and check with the docker ps command. Is it in a running state or not?

1 answer to this question.

0 votes

Here's something that you could try:

  • Check your port is mapping to you localhost so that it can access the container

    docker run -p 8000:8000 (rest of the command)
  • Also, change your listening port to "-b 127.0.0.1:8000" from "-b 0.0.0.0:8000". this is kinda requirement for docker to map ports. In docker ps you'll see 0.0.0.0:8000->8000

Now, check your localhost:8000 in your web browser to see if the app is working properly.

answered Jun 14, 2018 by ajs3033
• 7,300 points

Related Questions In DevOps Tools

0 votes
1 answer

Want a command to be executed in Salt only if a directory is empty

You should consider using this inside your ...READ MORE

answered Jun 12, 2018 in DevOps Tools by Damon Salvatore
• 5,980 points
1,479 views
0 votes
1 answer
0 votes
1 answer

How do I run “ant update” in Hybris with only “Update Running System”?

Here is what you can try. You can ...READ MORE

answered Jul 10, 2018 in DevOps Tools by Atul
• 10,240 points
6,842 views
0 votes
1 answer
+2 votes
1 answer
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,090 points
2,467 views
0 votes
1 answer

running comands as non-root user while using docker-maven plugin

Docker needs root access therefore maven commands ...READ MORE

answered Apr 30, 2018 in DevOps Tools by ajs3033
• 7,300 points
2,689 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP