1

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?

5
  • Does this answer your question? How restart a stopped docker container Commented Jun 7, 2021 at 12:03
  • Or this? stackoverflow.com/questions/41555884/… Commented Jun 7, 2021 at 12:03
  • Or this? stackoverflow.com/questions/30040971/… Commented Jun 7, 2021 at 12:04
  • Thanks for these threads. But in my situation container is successfully running, but the app inside it crashes Commented 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 me Commented Jun 7, 2021 at 13:26

1 Answer 1

4

I suggest you:

  1. Create the container with the restart policy set to always or unless-stopped or on-failure.
  2. Instrument Docker Health Check like HEALTHCHECK --interval=5m --timeout=3s CMD curl -f http://localhost/ || exit 1.
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! I didn't know that the HEALTHCHECK existed. I guess, I need to read the documentation more thoroughly

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.