gpt4 book ai didi

Docker overlay2文件夹吃磁盘

转载 作者:行者123 更新时间:2023-12-05 02:35:18 25 4
gpt4 key购买 nike

我对 docker overlay2 文件夹有问题。

当我在撰写本文时输入 du -sj/var/lib/docker/overlay2 时,它说:

85G overlay2/

它一直在成长。我尝试使用如下命令修剪系统:

docker system prune -a

但是输出是:

Total reclaimed space: 0B

我还尝试将 ma​​x-filema​​x-size 添加到我的 docker compose 中。添加这些行后,我重新创建了容器。但是问题依然存在,是否可以通过任何方式解决,只是停止占用磁盘空间?

编辑:

泊坞信息:

Server:
Containers: 10
Running: 10
Paused: 0
Stopped: 0
Images: 6
Server Version: 19.03.8
Storage Driver: overlay2
Backing Filesystem:
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local \logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
init version: fec3683
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.15.0-91-generic
Operating System: Ubuntu 18.04.4 LTS
OSType: linux
Architecture: x86_64
CPUs: 32
Total Memory: 62.86GiB
Name: machine
ID: TRX2:AJZG:LNJF:UCPW:MQQB:2PLR:R7KM:VHEV:KBOG:IBT4:JX4R:WR6V
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/\Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false\

docker 图像:(出于安全原因,我不会显示名称)

TAG IMAGE ID CREATED SIZE
latest 667ac029b200 2 years ago 7.6GB
latest cb9df5aac4ac 2 years ago 12.9GB
latest d445c0adc9a5 3 weeks ago 220MB
latest 227d9f0554d3 2 years ago 1.34GB
latest b80092729008 2 years ago 758MB
latest f32a97de94e1 2 years ago 25.8MB

最佳答案

#!/bin/bash
# Remove exited containers
/usr/bin/docker ps -a -q -f status=exited | xargs --no-run-if-empty docker rm -v

# Remove dangling images
/usr/bin/docker images -f "dangling=true" -q | xargs --no-run-if-empty docker rmi

# Remove unused images
/usr/bin/docker images | awk '/ago/ { print $3}' | xargs --no-run-if-empty docker rmi

# Remove dangling volumes
/usr/bin/docker volume ls -qf dangling=true | xargs --no-run-if-empty docker volume rm

使用 cron 运行。在我的例子中每小时

enter image description here

关于Docker overlay2文件夹吃磁盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70606161/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com