千家信息网

docker日志出现无法检索怎么办

发表于:2026-11-02 作者:千家信息网编辑
千家信息网最后更新 2026年11月02日,这篇文章主要介绍docker日志出现无法检索怎么办,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!日常检查服务的时候,从portainer那里进去看容器日志的时候,发现右上角出现
千家信息网最后更新 2026年11月02日docker日志出现无法检索怎么办

这篇文章主要介绍docker日志出现无法检索怎么办,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

日常检查服务的时候,从portainer那里进去看容器日志的时候,发现右上角出现红色的感叹号:Unable to retrieve container logs。

因为之前没出现过这样的问题,所以就先上服务器上用命令docker logs -f containerID看日志,发现日志也是动不了,还是停留在某个时间的日志记录上。

想了一下不应该是服务的日志打印出问题,先照着Google搜索了一遍,发现都没有跟我的问题相匹配的。因为日志有时能收集显示,有些日志不可以,应该是跟docker设置的日志引擎有问题。

本来是想整一套EFK的,但是感觉现在日志量还不够大,所以并没有修改docker的日志引擎,还是默认的journald

[root@ad-official xiaoxiao]# docker info|grep Logging WARNING: You're not using the default seccomp profileLogging Driver: journald

journald的官方文档上有这么一个说明:

man journald.conf ... RateLimitInterval=, RateLimitBurst= Configures the rate limiting that is applied to all messages generated on the system. If, in the time interval defined by RateLimitInterval=, more messages than specified in RateLimitBurst= are logged by a service, all further messages within the interval are dropped until the interval is over. A message about the number of dropped messages is generated. This rate limiting is applied per-service, so that two services which log do not interfere with each other's limits. Defaults to 1000 messages in 30s. The time specification for RateLimitInterval= may be specified in the following units: "s", "min", "h", "ms", "us". To turn off any kind of rate limiting, set either value to 0. ...

这里写了默认30秒内只能接收1000条日志,看到这里就能明白了,因为前阵子刚在docker发布了一个单日日志文件大小差不多达到3G的服务,导致到了其他服务的日志也受到了影响,大量的日志被journald丢弃,所以我们修改一下配置就没有问题了。

打开/etc/systemd/journald.conf文件,将RateLimitBurst从默认的1000修改成5000,根据自己目前的日志输出量进行调整:

[root@ad-official log]# cat /etc/systemd/journald.conf# This file is part of systemd.## systemd is free software; you can redistribute it and/or modify it# under the terms of the GNU Lesser General Public License as published by# the Free Software Foundation; either version 2.1 of the License, or# (at your option) any later version.## Entries in this file show the compile time defaults.# You can change settings by editing this file.# Defaults can be restored by simply deleting this file.## See journald.conf(5) for details.[Journal]#Storage=auto#Compress=yes#Seal=yes#SplitMode=uid#SyncIntervalSec=5m#RateLimitInterval=30sRateLimitBurst=5000#SystemMaxUse=#SystemKeepFree=#SystemMaxFileSize=#RuntimeMaxUse=#RuntimeKeepFree=#RuntimeMaxFileSize=#MaxRetentionSec=#MaxFileSec=1monthForwardToSyslog=no#ForwardToKMsg=no#ForwardToConsole=noForwardToWall=no#TTYPath=/dev/console#MaxLevelStore=debug#MaxLevelSyslog=debug#MaxLevelKMsg=notice#MaxLevelConsole=info#MaxLevelWall=emerg#LineMax=48K

顺便将ForwardToSyslog和ForwardToWall设置成no,因为默认是yes,会导致我们清理了journal的日志文件,而Syslog中的没有清除掉,慢慢的就会将磁盘占满。

然后重启一下journald就可以恢复正常使用啦:systemctl restart systemd-journald.service

以上是"docker日志出现无法检索怎么办"这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注行业资讯频道!

日志 问题 服务 文件 怎么办 检索 内容 引擎 时候 篇文章 还是 差不多 不够 价值 兴趣 单日 命令 大小 官方 容器 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 大白互联网科技 互联网金融和金融科技 卓越科技互联网 招聘 金融科技和互联网金融 互联网公司会议桌创意科技软装饰 宁波青枫互联网科技有限公司 欧洲十大科技互联网公司 互联网科技创新服务 燊美集互联网科技有限公司 爱医互联网络科技 科技互联网海报 互联网第三次科技革命特征 互联网金融科技公司的优势 上海钢联属于互联网科技股吗 互联网科技年终奖 互联网科技手机排行榜 互联网科技职业技能培训学校 现代互联网科技公司 互联网科技创业计划的风险分析 科技发展第三阶段互联网时代 猫创互联网科技 随着互联网科技发展 厦门比较好的科技互联网公司 链环科技传统企业怎么转型互联网 为客找房互联网科技公司怎么样 高科技互联网套路 南京一网一红互联网科技有限公司 瑞安市蟠桃会互联网科技有限公司 恒生科技互联网指数十大成分股 株洲百竞科技的互联网营销顾问
0