大网数据广告活动
服务器运维问答

How to monitor docker container restarting behavior?

· 52CE 我爱测

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 hou…

问题原文

原帖链接 · LawrenceH · CC BY-SA 3.0

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..

社区高分解答

原帖链接 · Rick · CC BY-SA 3.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-04-25)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。