docker volume prune

描述移除未使用的本地卷
用法docker volume prune [OPTIONS]

描述

移除所有未使用的本地卷。未使用的本地卷是指未被任何容器引用的卷。預設情況下,它只移除匿名卷。

選項

選項預設值描述
-a, --allAPI 1.42+ 移除所有未使用的卷,不只是匿名卷
--filter提供篩選值(例如 label=<label>
-f, --force不提示確認

示例

$ 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=<key>, label=<key>=<value>, label!=<key>, 或 label!=<key>=<value>) - 僅移除具有(或不具有,如果使用 label!=...)指定標籤的卷。

label 篩選器接受兩種格式。一種是 label=... (label=<key>label=<key>=<value>),它會移除具有指定標籤的卷。另一種格式是 label!=... (label!=<key>label!=<key>=<value>),它會移除不具有指定標籤的卷。