docker - docker 巨大的log文件: prune daemon.json
访问量: 21
refer to: https://www.reddit.com/r/docker/comments/1kflzio/apt_update_error_with_latest_ubuntu_container/
更新:找到根源了:服务器的空间不够
docker system prune
docker system prune -a --volumes
使用 du -a / | sort -n -r | head -n 2000 > /tmp/largest_nls
发现,有一个超级巨大的log: 325511780 /var/lib/docker/containers/09d44ba32c76248178d852ac5c2d5c32f7e325160420ade351f6260434923767/09d44ba32c76248178d852ac5c2d5c32f7e325160420ade351f6260434923767-json.log
325G.
解决办法:
vim /etc/docker/daemon.json
{
"log-driver": "json-file",
"log-opts": {
"max-size": "100m", // 单个日志文件最大100MB
"max-file": "3" // 最多保留3个日志文件
}
}
然后重启docker:
systemctl daemon-reload && systemctl restart docker
也可以先手动运行这个命令,先把空间腾出来:
truncate -s 0 /var/lib/docker/containers/09d44ba32c76248178d852ac5c2d5c32f7e325160420ade351f6260434923767/09d44ba32c76248178d852ac5c2d5c32f7e325160420ade351f6260434923767-json.log
原文:
今天遇到这个问题,怎么样都搞不定,最后用 docker system prune 搞定了。
root@localhost:/opt/app/wazuh/wazuh_server# docker build . [+] Building 2.7s (5/5) FINISHED docker:default => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 2.42kB 0.0s => [internal] load metadata for docker.io/library/ubuntu:24.04 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s => CACHED [1/2] FROM docker.io/library/ubuntu:24.04 0.0s => ERROR [2/2] RUN apt update 2.5s ------ > [2/2] RUN apt update: 0.307 0.307 WARNING: apt does not have a stable CLI interface. Use with caution in scripts. 0.307 0.776 Get:1 http://security.ubuntu.com/ubuntu noble-security InRelease [126 kB] 0.796 Get:2 http://archive.ubuntu.com/ubuntu noble InRelease [256 kB] 1.552 Err:1 http://security.ubuntu.com/ubuntu noble-security InRelease 1.552 At least one invalid signature was encountered. 1.823 Err:2 http://archive.ubuntu.com/ubuntu noble InRelease 1.823 At least one invalid signature was encountered. 1.929 Get:3 http://archive.ubuntu.com/ubuntu noble-updates InRelease [126 kB] 2.073 Err:3 http://archive.ubuntu.com/ubuntu noble-updates InRelease 2.073 At least one invalid signature was encountered. 2.211 Get:4 http://archive.ubuntu.com/ubuntu noble-backports InRelease [126 kB] 2.365 Err:4 http://archive.ubuntu.com/ubuntu noble-backports InRelease 2.365 At least one invalid signature was encountered. 2.370 Reading package lists... 2.401 W: GPG error: http://security.ubuntu.com/ubuntu noble-security InRelease: At least one invalid signature was encountered. 2.401 E: The repository 'http://security.ubuntu.com/ubuntu noble-security InRelease' is not signed. 2.401 W: GPG error: http://archive.ubuntu.com/ubuntu noble InRelease: At least one invalid signature was encountered. 2.401 E: The repository 'http://archive.ubuntu.com/ubuntu noble InRelease' is not signed. 2.401 W: GPG error: http://archive.ubuntu.com/ubuntu noble-updates InRelease: At least one invalid signature was encountered. 2.401 E: The repository 'http://archive.ubuntu.com/ubuntu noble-updates InRelease' is not signed. 2.401 W: GPG error: http://archive.ubuntu.com/ubuntu noble-backports InRelease: At least one invalid signature was encountered. 2.401 E: The repository 'http://archive.ubuntu.com/ubuntu noble-backports InRelease' is not signed. ------ Dockerfile:10 -------------------- 8 | 9 | # 再正常执行apt update 10 | >>> RUN apt update 11 | 12 | #RUN cp /etc/apt/sources.list /etc/apt/sources.list.bak && \ -------------------- ERROR: failed to build: failed to solve: process "/bin/sh -c apt update" did not complete successfully: exit code: 100之后:
root@localhost:/opt/app/wazuh/wazuh_server# docker system prune WARNING! This will remove: - all stopped containers - all networks not used by at least one container - all dangling images - unused build cache Are you sure you want to continue? [y/N] y Deleted Containers: eef620d28da0a60dc400a2abab5be802ded603d161d7282f34a7ffa9d00848f5 2d655b3f5a702da2dba6b17ca4311e4f01ac3e24b2a5ef7d29ce805b24dcbbce b2470b5ca70ce421e02e3d45c73cffba8eadab81086b5809b71a55727721e4a5 c60d816bb142dd44b8450959203717f7d89102f43c87aefb29da1d567beeb521 7f4da4c70179936ea666e71ec15616149d10615c97d2744ce096dd60e7a39993 a7e245854515453f8e0c19a2ce77d7a6b3e59513546ab5277c887d975490c4b3 b2889c22ebe534ff560d0b196bd4238ecd8ee7e2a143f07db3541591e69969ac 0c2c5efc764c3951e93e2b92209b25e5f88c383f6a193e2edb7a8578b752b621 1789c7fbc0ef29f1636326eed33360938ce7b61a5eb3e3e4c7bd05e267fada35 3b68095d1596be72d97975e871249b1f4c22d91e2fe3e7137b4aff8bd6b07978 750bb10428f3f611a568cd2cd16a7e3ef04545dcce4dba7336a33929801093e3 820d945b95291d994f8f81b98e7ae5d5cfd2fb4713e2a444d28f4d9316da89b1 Deleted Networks: custom_service_chatwoot_default app_default app_mail-network Deleted Images: deleted: sha256:f41d5372a02cfd91fc70bed9d8b8fb495dc0ae8d7d97ddd25aaed803468f6a54 Deleted build cache objects: wirrdkpdim9e0g1g8zhepxq2j eh018dopnfum2l7zm5d5prfo1 h7rg1gmioxp4hzzks8h2iw07r k2cb6nq7r3bllvrg5pwq3zhk3 5thlnp7b0fnsdi00spuurep43 w5uv8o3j9k9lbnzh7s04c1595 ... root@localhost:/opt/app/wazuh/wazuh_server# docker build . [+] Building 38.2s (6/6) FINISHED docker:default => [internal] load build definition from Dockerfile 0.1s => => transferring dockerfile: 2.42kB 0.0s => [internal] load metadata for docker.io/library/ubuntu:24.04 0.0s => [internal] load .dockerignore 0.1s => => transferring context: 2B 0.0s => CACHED [1/2] FROM docker.io/library/ubuntu:24.04 0.0s => [2/2] RUN apt update 36.5s => exporting to image 1.3s => => exporting layers 1.2s => => writing image sha256:b226efd1fadaa88c0aea85cc2be91e0b0a9d6e505b6c070b062e16ab3210b33b