Docker日志大小限制

Code 代码
2020年2月4日 ~

全局限制Docker日志

sudo vi /etc/docker/daemon.json
 
{
    "log-driver":"json-file",
    "log-opts": {"max-size":"500m", "max-file":"3"}
}
 
sudo systemctl restart docker

全局限制系统日志

Ubuntu16.04以上系统日志采用systemd-journald.service服务管理日志,一些详细配置可参考:https://www.chenweiliang.com/cwl-1141.html

限制journald日志大小只需要修改journald.conf内的参数,增加一下:

SystemMaxUse=200M

重启服务

sudo systemctl restart systemd-journald.service

日志清理

sudo journalctl --vacuum-size=500M
sudo journalctl --vacuum-time=2d

标签

Jerry

大道至简,行者无疆。

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.