1. The disk is full after docker runs for a while
Since releases and builds are often required, server machines are chosen from less disk space.
50G
Especially when building the front end and building golang, the image file must be downloaded every time. There will be a lot of build cache.
On the contrary, the real useful mirror image does not take up much space.
# df -lh
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 3.8G 0 3.8G 0% /dev
tmpfs 3.8G 24K 3.8G 1% /dev/shm
tmpfs 3.8G 908K 3.8G 1% /run
tmpfs 3.8G 0 3.8G 0% /sys/fs/cgroup
/dev/vda1 50G 49G 0 100% /
tmpfs 773M 0 773M 0% /run/user/0
overlay 50G 49G 0 100% /data/docker/overlay2/ff113c990677624e519763d002699fae39bcf58c0e005a7100253435718eb2a0/merged
overlay 50G 49G 0 100% /data/docker/overlay2/cefe857f8a1a40cd3d4fc9f95352fe71aa4a3e85210412e89612d97ad54f7b4d/merged
overlay 50G 49G 0 100% /data/docker/overlay2/f39ac164064163d69e8474b070d870a22ccb4dcf4f8b907d9b5ed58675de8348/merged
overlay 50G 49G 0 100% /data/docker/overlay2/18237ec943d64472a4d42789b70892cdc0727d7cf65cefc4aede49068241a4dc/merged
2, docker official cleaning
First check the disk usage using the command:
# docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 4 4 764.4MB 0B (0%)
Containers 4 3 2B 0B (0%)
Local Volumes 0 0 0B 0B
Build Cache 274 0 32.84GB 32.84GB
Then use the cleanup command:
# docker system prune -a
WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all images without at least one container associated to them
- all build cache
Are you sure you want to continue? [y/N] y
Deleted Containers:
1ff34a648fa8b47476dc76080874d5c6c1d73fd5bbac79fff4cb0e3f639673bd
Deleted Images:
untagged: redis:bullseye
untagged:
deleted: sha256:eca1379fe8b541831fd5ce4a252c263db0cef4efbfd428a94225dc020aaeb1af
deleted: sha256:21acda8c08f1a6109e2fb61ed010d368ee6581cf30128cdaab0e6b91dabffc22
...
Deleted build cache objects:
jcgsxqae4dviszzlx6g2ygfou
1chpzs27wr8a5x41hoshzd8pd
...
7c7wsj7e2rcu3o49xbgnoqid9
4f16uvjz4h7bsklayvfcftsf3
Total reclaimed space: 32.95GB
Cleaned up space:
# df -lh
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 3.8G 0 3.8G 0% /dev
tmpfs 3.8G 24K 3.8G 1% /dev/shm
tmpfs 3.8G 828K 3.8G 1% /run
tmpfs 3.8G 0 3.8G 0% /sys/fs/cgroup
/dev/vda1 50G 6.4G 41G 14% /
tmpfs 773M 0 773M 0% /run/user/0
overlay 50G 6.4G 41G 14% /data/docker/overlay2/18237ec943d64472a4d42789b70892cdc0727d7cf65cefc4aede49068241a4dc/merged
overlay 50G 6.4G 41G 14% /data/docker/overlay2/f39ac164064163d69e8474b070d870a22ccb4dcf4f8b907d9b5ed58675de8348/merged
overlay 50G 6.4G 41G 14% /data/docker/overlay2/ff113c990677624e519763d002699fae39bcf58c0e005a7100253435718eb2a0/merged
3. Reduced to 14%
Save a lot of space. The mirror used at the same time is still there.
Very convenient. You can continue to use docker.