孤立Docker安装的主机卷? [英] Orphaned Docker mounted host volumes?

查看:128
本文介绍了孤立Docker安装的主机卷?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚检查了我的/ var / lib / docker / volumes文件夹,发现这个文件夹名为Docker UUID,每个文件夹都包含一个config.json文件,内容沿着

I just inspected my /var/lib/docker/volumes folder and discovered that is bursting with folders named as Docker UUIDs each of which contain a config.json file with contents along the lines of

{"ID":"UUID","Path":"/path/to/mounted/volume","IsBindMount":true,"Writable":true}

其中

/path/to/mounted/volume

是文件夹的路径在某一点上安装到-v开关的docker容器的主机。我有这样的文件夹可追溯到Docker的实验开始,即大约3周前。

is the path to the folder on the host that was mounted on to a docker container with the -v switch at some point. I have such folders dating back to the start of my experiments with Docker, i.e. about 3 weeks ago.

有问题的容器停了下来,码头工作了很长时间以前,我看不到这些条目没有超过他们的销售日期。这就提出了一个问题 - 剩下的是我看到一个错误,还是需要手动丢弃/ var / lib / docker / volumes中的这些条目?

The containers in question were stopped and docker rm'ed a long time ago so I cannot see that those entries are not past their sell-by date. This begs the question - is the left over I am seeing a bug or does one need to manually discard such entries from /var/lib/docker/volumes?

推荐答案

对于Docker 1.9及更高版本,有一种原生方式:

For Docker 1.9 and up there's a native way:

列出所有孤儿卷与

$ docker volume ls -qf dangling = true

消除所有这些与

$ docker volume rm $(docker volume ls -qf dangling = true) code>

$ docker volume rm $(docker volume ls -qf dangling=true)

这篇关于孤立Docker安装的主机卷?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆