github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/cli/docs/reference/commandline/network_prune.md (about) 1 --- 2 title: "network prune" 3 description: "Remove unused networks" 4 keywords: "network, prune, delete" 5 --- 6 7 # network prune 8 9 ```markdown 10 Usage: docker network prune [OPTIONS] 11 12 Remove all unused networks 13 14 Options: 15 --filter filter Provide filter values (e.g. 'until=<timestamp>') 16 -f, --force Do not prompt for confirmation 17 --help Print usage 18 ``` 19 20 ## Description 21 22 Remove all unused networks. Unused networks are those which are not referenced 23 by any containers. 24 25 ## Examples 26 27 ```bash 28 $ docker network prune 29 30 WARNING! This will remove all custom networks not used by at least one container. 31 Are you sure you want to continue? [y/N] y 32 Deleted Networks: 33 n1 34 n2 35 ``` 36 37 ### Filtering 38 39 The filtering flag (`--filter`) format is of "key=value". If there is more 40 than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`) 41 42 The currently supported filters are: 43 44 * until (`<timestamp>`) - only remove networks created before given timestamp 45 * label (`label=<key>`, `label=<key>=<value>`, `label!=<key>`, or `label!=<key>=<value>`) - only remove networks with (or without, in case `label!=...` is used) the specified labels. 46 47 The `until` filter can be Unix timestamps, date formatted 48 timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed 49 relative to the daemon machine’s time. Supported formats for date 50 formatted time stamps include RFC3339Nano, RFC3339, `2006-01-02T15:04:05`, 51 `2006-01-02T15:04:05.999999999`, `2006-01-02Z07:00`, and `2006-01-02`. The local 52 timezone on the daemon will be used if you do not provide either a `Z` or a 53 `+-00:00` timezone offset at the end of the timestamp. When providing Unix 54 timestamps enter seconds[.nanoseconds], where seconds is the number of seconds 55 that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap 56 seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a 57 fraction of a second no more than nine digits long. 58 59 The `label` filter accepts two formats. One is the `label=...` (`label=<key>` or `label=<key>=<value>`), 60 which removes networks with the specified labels. The other 61 format is the `label!=...` (`label!=<key>` or `label!=<key>=<value>`), which removes 62 networks without the specified labels. 63 64 The following removes networks created more than 5 minutes ago. Note that 65 system networks such as `bridge`, `host`, and `none` will never be pruned: 66 67 ```bash 68 $ docker network ls 69 70 NETWORK ID NAME DRIVER SCOPE 71 7430df902d7a bridge bridge local 72 ea92373fd499 foo-1-day-ago bridge local 73 ab53663ed3c7 foo-1-min-ago bridge local 74 97b91972bc3b host host local 75 f949d337b1f5 none null local 76 77 $ docker network prune --force --filter until=5m 78 79 Deleted Networks: 80 foo-1-day-ago 81 82 $ docker network ls 83 84 NETWORK ID NAME DRIVER SCOPE 85 7430df902d7a bridge bridge local 86 ab53663ed3c7 foo-1-min-ago bridge local 87 97b91972bc3b host host local 88 f949d337b1f5 none null local 89 ``` 90 91 ## Related commands 92 93 * [network disconnect ](network_disconnect.md) 94 * [network connect](network_connect.md) 95 * [network create](network_create.md) 96 * [network ls](network_ls.md) 97 * [network inspect](network_inspect.md) 98 * [network rm](network_rm.md) 99 * [Understand Docker container networks](https://docs.docker.com/network/) 100 * [system df](system_df.md) 101 * [container prune](container_prune.md) 102 * [image prune](image_prune.md) 103 * [volume prune](volume_prune.md) 104 * [system prune](system_prune.md)