I have a web application in a docker container, and it processes requests via HTTP. But, when there are too many requests app stops working. I am busy with other tasks, so don't really have time to fix it. When it crashes, the container is still running, but the app responds with a 500 error. Are there any ways to track it and restart docker automatically, because I don't have an option to check it all the time?
Asked
Active
Viewed 690 times
1
-
Does this answer your question? [How restart a stopped docker container](https://stackoverflow.com/questions/39666950/how-restart-a-stopped-docker-container) – Nico Haase Jun 07 '21 at 12:03
-
Or this? https://stackoverflow.com/questions/41555884/docker-what-does-docker-run-restart-always-actually-do – Nico Haase Jun 07 '21 at 12:03
-
Or this? https://stackoverflow.com/questions/30040971/how-to-automatically-monitor-and-restart-the-docker-container-when-it-crashes-do – Nico Haase Jun 07 '21 at 12:04
-
Thanks for these threads. But in my situation container is successfully running, but the app inside it crashes – a b Jun 07 '21 at 12:08
-
Then why not restart your application within that container? If the container itself is not the problem, this does not look related to Docker itself to me – Nico Haase Jun 07 '21 at 13:26
1 Answers
3
I suggest you:
- Create the container with the restart policy set to
always
orunless-stopped
oron-failure
. - Instrument Docker Health Check like
HEALTHCHECK --interval=5m --timeout=3s CMD curl -f http://localhost/ || exit 1
.

Antonio Petricca
- 8,891
- 5
- 36
- 74
-
Thanks! I didn't know that the HEALTHCHECK existed. I guess, I need to read the documentation more thoroughly – a b Jun 07 '21 at 12:04