问题描述
我对存储有一些问题. /var/lib/docker/devicemapper/文件夹占用了我50%的存储空间.
I have some problem about the storage. The folder /var/lib/docker/devicemapper/ is taking 50% of my storage.
在文件夹/var/lib/docker/devicemapper/mnt 中,我有很多空文件夹.
In the folder /var/lib/docker/devicemapper/mnt, I have many empty folders.
如何正确清理docker devicemapper 并删除所有未使用的映射?
How can I properly clean docker devicemapper and remove all unused mapping ?
推荐答案
在最新版本的Docker中,您可以看到用于以下用途的空间:
With recent versions of Docker you can see the space used with:
docker system df
并用以下方法修剪:
docker system prune
上面的命令结合了存在于卷,容器,图像和网络的 prune 命令:
The above command combines the prune command that exists for volumes, containers, images and networks:
docker volume prune
docker container prune
docker image prune
docker network prune
每个命令都有一个--help
选项,记录了一个-f
(--force
)选项,以避免向您提出问题.必须小心使用.
Each command has a --help
option documenting a -f
(--force
) option to avoid asking you questions. It must be used with care.
-o-
在旧版本的Docker上,我运行了脚本:
On older versions of Docker I ran the script:
#!/bin/bash
# Remove dead containers (and their volumes)
docker ps -f status=dead --format '{{ .ID }}' | xargs -r docker rm -v
# Remove dangling volumes
docker volume ls -qf dangling=true | xargs -r docker volume rm
# Remove untagged ("<none>") images
docker images --digests --format '{{.Repository}}:{{.Tag}}@{{.Digest}}' | sed -rne 's/([^>]):<none>@/\1@/p' | xargs -r docker rmi
# Remove dangling images
docker images -qf dangling=true | xargs -r docker rmi
# Remove temporary files
rm -f /var/lib/docker/tmp/*
这篇关于如何正确清理docker devicemapper文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!