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?
-
Does this answer your question? How restart a stopped docker containerNico Haase– Nico Haase2021-06-07 12:03:02 +00:00Commented Jun 7, 2021 at 12:03
-
Or this? stackoverflow.com/questions/41555884/…Nico Haase– Nico Haase2021-06-07 12:03:30 +00:00Commented Jun 7, 2021 at 12:03
-
Or this? stackoverflow.com/questions/30040971/…Nico Haase– Nico Haase2021-06-07 12:04:02 +00:00Commented Jun 7, 2021 at 12:04
-
Thanks for these threads. But in my situation container is successfully running, but the app inside it crashesa b– a b2021-06-07 12:08:02 +00:00Commented Jun 7, 2021 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 meNico Haase– Nico Haase2021-06-07 13:26:11 +00:00Commented Jun 7, 2021 at 13:26
Add a comment
|
1 Answer
I suggest you:
- Create the container with the restart policy set to
alwaysorunless-stoppedoron-failure. - Instrument Docker Health Check like
HEALTHCHECK --interval=5m --timeout=3s CMD curl -f http://localhost/ || exit 1.
1 Comment
a b
Thanks! I didn't know that the HEALTHCHECK existed. I guess, I need to read the documentation more thoroughly