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