Docker Network Prune
| 描述 | 删除所有未使用的网络 |
|---|---|
| 用法 | docker network prune [OPTIONS] |
描述
删除所有未使用的网络。未使用的网络是未引用的网络 通过任何容器。
选项
| 选择 | 违约 | 描述 |
|---|---|---|
--filter | 提供筛选条件值(例如until=<timestamp>) | |
-f, --force | 不提示确认 |
例子
$ docker network prune
WARNING! This will remove all custom networks not used by at least one container.
Are you sure you want to continue? [y/N] y
Deleted Networks:
n1
n2
筛选 (--filter)
筛选标志 (--filter) 格式为 “key=value”。如果还有更多
than 一个 filter,然后传递多个标志(例如--filter "foo=bar" --filter "bif=baz")
当前支持的筛选器包括:
- 直到 (
<timestamp>) - 仅删除在给定时间戳之前创建的网络 - 标签 (
label=<key>,label=<key>=<value>,label!=<key>或label!=<key>=<value>) - 仅删除具有 (或没有,以防万一)label!=...使用)指定的标签。
这untilfilter 可以是 Unix 时间戳、日期格式
timestamp 或 ParseDuration 支持的 Go 持续时间字符串(例如10m,1h30m) 计算
相对于守护程序机器的时间。支持的日期格式
格式化的时间戳包括 RFC3339Nano、RFC3339、2006-01-02T15:04:05,2006-01-02T15:04:05.999999999,2006-01-02T07:00和2006-01-02.本地
如果您未提供Z或+-00:00时间戳末尾的 timezone 偏移量。提供 Unix 时
timestamps 输入 seconds[.nanoseconds],其中 seconds 是秒数
自 1970 年 1 月 1 日午夜 (UTC/GMT) 以来经过的日期,不包括闰
秒(又名 Unix 纪元或 Unix 时间),可选的 .nanoseconds 字段是一个
长度不超过 9 位数字的几分之一秒。
这labelfilter 接受两种格式。一个是label=... (label=<key>或label=<key>=<value>),
,这将删除具有指定标签的网络。另一个
format 是label!=... (label!=<key>或label!=<key>=<value>),这会删除
网络。
以下内容将删除 5 分钟前创建的网络。请注意,
系统网络,例如bridge,host和none永远不会被修剪:
$ docker network ls
NETWORK ID NAME DRIVER SCOPE
7430df902d7a bridge bridge local
ea92373fd499 foo-1-day-ago bridge local
ab53663ed3c7 foo-1-min-ago bridge local
97b91972bc3b host host local
f949d337b1f5 none null local
$ docker network prune --force --filter until=5m
Deleted Networks:
foo-1-day-ago
$ docker network ls
NETWORK ID NAME DRIVER SCOPE
7430df902d7a bridge bridge local
ab53663ed3c7 foo-1-min-ago bridge local
97b91972bc3b host host local
f949d337b1f5 none null local