...

Text file src/github.com/docker/cli/docs/reference/commandline/network_prune.md

Documentation: github.com/docker/cli/docs/reference/commandline

     1# network prune
     2
     3<!---MARKER_GEN_START-->
     4Remove 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
    18Remove all unused networks. Unused networks are those which are not referenced
    19by any containers.
    20
    21## Examples
    22
    23```console
    24$ docker network prune
    25
    26WARNING! This will remove all custom networks not used by at least one container.
    27Are you sure you want to continue? [y/N] y
    28Deleted Networks:
    29n1
    30n2
    31```
    32
    33### <a name="filter"></a> Filtering (--filter)
    34
    35The filtering flag (`--filter`) format is of "key=value". If there is more
    36than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
    37
    38The 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
    43The `until` filter can be Unix timestamps, date formatted
    44timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed
    45relative to the daemon machine’s time. Supported formats for date
    46formatted 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
    48timezone 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
    50timestamps enter seconds[.nanoseconds], where seconds is the number of seconds
    51that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap
    52seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a
    53fraction of a second no more than nine digits long.
    54
    55The `label` filter accepts two formats. One is the `label=...` (`label=<key>` or `label=<key>=<value>`),
    56which removes networks with the specified labels. The other
    57format is the `label!=...` (`label!=<key>` or `label!=<key>=<value>`), which removes
    58networks without the specified labels.
    59
    60The following removes networks created more than 5 minutes ago. Note that
    61system networks such as `bridge`, `host`, and `none` will never be pruned:
    62
    63```console
    64$ docker network ls
    65
    66NETWORK ID          NAME                DRIVER              SCOPE
    677430df902d7a        bridge              bridge              local
    68ea92373fd499        foo-1-day-ago       bridge              local
    69ab53663ed3c7        foo-1-min-ago       bridge              local
    7097b91972bc3b        host                host                local
    71f949d337b1f5        none                null                local
    72
    73$ docker network prune --force --filter until=5m
    74
    75Deleted Networks:
    76foo-1-day-ago
    77
    78$ docker network ls
    79
    80NETWORK ID          NAME                DRIVER              SCOPE
    817430df902d7a        bridge              bridge              local
    82ab53663ed3c7        foo-1-min-ago       bridge              local
    8397b91972bc3b        host                host                local
    84f949d337b1f5        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)

View as plain text