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

Clearing/Deleting Docker Logs

· 52CE 我爱测

On our docker implementation on GCE, we are running out of space on the root file system. Since images themselves are stored on a separate 1TB volume, the images themselves shouldn't be the problem. One candidate are the centrali…

问题原文

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

On our docker implementation on GCE, we are running out of space on the root file system.

Since images themselves are stored on a separate 1TB volume, the images themselves shouldn't be the problem.

One candidate are the centralized logfiles that Docker itself stores (a json file somewhere?), does anyone know where those files/file are/is located, and how we can logrotate/truncate them?

已采纳解答

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

First, I'm using docker 1.1.2 for both client and server, this answer may be obsolete for newer versions of docker as docker evolve quickly.

Location of the file

Find your docker directory. On systems that use apt/debian style system, the package installed by the docker repository https://get.docker.com/ubuntu use /var/lib/docker. Chances are that directory is in the same place on other systems (can't confirm).

under containers/**CONTAINER_ID** you'll find infos about the container. In the file **CONTAINER_ID**-json.log in that folder, you'll find a file with all the logs for that container. It may look like a json file, it's not. It's a flow a json structures, one per line, each containing one log line (each line ends by a } and the next one starts with a {, thus it's not a valid json as a whole).

Example location: - /var/lib/docker/containers/05b6053c41a2130afd6fc3b158bda4e605b6053c41a2130afd6fc3b158bda4e6/05b6053c41a2130afd6fc3b158bda4e605b6053c41a2130afd6fc3b158bda4e6-json.log

Editing/Altering that file

I suggest you to use that path to see wether or not it's the reason why you're running out of space, but not to log rotate them.

I would rather make sure the container doesn't log too much lines (by using a CMD in the dockerfile that either redirect the output of you process to a file in a volume or to /dev/null - with logs enabled with configuration - and I would then logrotate the log files with another container)

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

资料来源与适用范围

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

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

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