How to monitor docker container restarting behavior?

currently I'm hosting several containers using Docker and realized that some containers seem to keep restarting by themself.

When using the command, docker ps -a, I saw the column status is always like "Up 5 minutes" or "Up 2 hours" and in the actual website, I have seen the downtime when the container is restarting itself and this is happening like multiple times per day.

I have tried with docker logs and look for documentation on the restarting behaviors and so far have no luck to find out why. Can anyone share me some lights on what would trigger the restart of the docker containers? Do they restart whe the host machine ran out of RAM? Is there any tools that I can track this behavior?

Thanks for your help..


Usually, Docker containers do not restart out of the blue. It is a bit strange that your log files do not show anything suggesting a restart of the container(s). How many RAM do you have available on your host machine when all containers run (free -m)?

One option could be to log/monitor the output of docker events (docs) for a while and see if some weird restart behavior occurs, and at what times. Or you can simply use since and until to go back in the past.

Another option could be to look at the daemon logs, but I am not sure whether restarts et cetera are logged in detail there.