docker volume prune

DescriptionRemove unused local volumes
Usagedocker volume prune [OPTIONS]

描述

删除所有未使用的本地卷。未使用的本地卷是指未被任何容器引用的卷。默认情况下,它只删除匿名卷。

选项

OptionDefaultDescription
-a, --allAPI 1.42+ Remove all unused volumes, not just anonymous ones
--filterProvide filter values (e.g. label=<label>)
-f, --forceDo not prompt for confirmation

示例

$ docker volume prune

WARNING! This will remove anonymous local volumes not used by at least one container.
Are you sure you want to continue? [y/N] y
Deleted Volumes:
07c7bdf3e34ab76d921894c2b834f073721fccfbbcba792aa7648e3a7a664c2e
my-named-vol

Total reclaimed space: 36 B

过滤 (--all, -a)

使用--all标志来删除未使用的匿名和命名卷。

过滤 (--filter)

过滤标志(--filter)的格式为“key=value”。如果有多个过滤器,则传递多个标志(例如,--filter "foo=bar" --filter "bif=baz"

当前支持的过滤器有:

  • 标签 (label=, label==, label!=, 或 label!==) - 仅移除具有(或不具有,在使用 label!=... 的情况下)指定标签的卷。

label 过滤器接受两种格式。一种是 label=...label=label==),它会移除具有指定标签的卷。另一种格式是 label!=...label!=label!==),它会移除没有指定标签的卷。