英文:
docker volume prune not deleting unused volumes
问题
我的理解是 docker volume prune
应该删除不再与容器关联的卷。
在本地,我有:
$ docker volume ls | head -n 2
DRIVER VOLUME NAME
local 0d4cd922a4ed3e970726b1edb860c7dda3ae1e47f812585d9517d512ae70d5cf
我确认它没有与容器关联,通过:
$ docker ps -a --filter volume=0d4cd922a4ed3e970726b1edb860c7dda3ae1e47f812585d9517d512ae70d5cf
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
因此,我期望这个卷会被删除,但不幸的是:
$ docker volume prune
警告!这将删除所有不再被至少一个容器使用的本地卷。
您确定要继续吗? [y/N] y
Total reclaimed space: 0B
$ docker volume ls | head -n 2
DRIVER VOLUME NAME
local 0d4cd922a4ed3e970726b1edb860c7dda3ae1e47f812585d9517d512ae70d5cf
我漏掉了什么?
英文:
My understanding is docker volume prune
should delete volumes which are no longer associated with containers.
Locally I have
$ docker volume ls | head -n 2
DRIVER VOLUME NAME
local 0d4cd922a4ed3e970726b1edb860c7dda3ae1e47f812585d9517d512ae70d5cf
I confirm it doesn't have an associated container via
$ docker ps -a --filter volume=0d4cd922a4ed3e970726b1edb860c7dda3ae1e47f812585d9517d512ae70d5cf
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
therefore I expect this volume to be deleted, but alas
$ docker volume prune
WARNING! This will remove all local volumes not used by at least one container.
Are you sure you want to continue? [y/N] y
Total reclaimed space: 0B
$ docker volume ls | head -n 2
DRIVER VOLUME NAME
local 0d4cd922a4ed3e970726b1edb860c7dda3ae1e47f812585d9517d512ae70d5cf
what am I missing ?
答案1
得分: 10
这可能是在 Docker CLI 的 GitHub 存储库中提到的问题:https://github.com/docker/cli/issues/4028
显然,Docker 版本 23 不再删除匿名卷(就像您的卷似乎是的),当运行 docker volume prune
时。要获得原始行为,您可以使用 docker volume prune --filter all=1
。
英文:
This is probably the issue mentioned in the docker cli github repo here: https://github.com/docker/cli/issues/4028
Apparently docker version 23 no longer deletes anonymous volumes (like your volume seems to be) when running docker volume prune
. To get the original behavior you can use docker volume prune --filter all=1
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论