2016-10-14 18:30:36 -04:00
|
|
|
---
|
|
|
|
title: "network ls"
|
|
|
|
description: "The network ls command description and usage"
|
2016-11-03 18:48:30 -04:00
|
|
|
keywords: "network, list, user-defined"
|
2016-10-14 18:30:36 -04:00
|
|
|
---
|
2015-09-28 21:57:03 -04:00
|
|
|
|
|
|
|
# docker network ls
|
|
|
|
|
2016-07-07 14:43:18 -04:00
|
|
|
```markdown
|
|
|
|
Usage: docker network ls [OPTIONS]
|
2015-09-28 21:57:03 -04:00
|
|
|
|
2016-07-07 14:43:18 -04:00
|
|
|
List networks
|
|
|
|
|
|
|
|
Aliases:
|
|
|
|
ls, list
|
|
|
|
|
|
|
|
Options:
|
2016-11-24 02:39:14 -05:00
|
|
|
-f, --filter filter Provide filter values (e.g. 'driver=bridge')
|
|
|
|
--format string Pretty-print networks using a Go template
|
|
|
|
--help Print usage
|
|
|
|
--no-trunc Do not truncate the output
|
|
|
|
-q, --quiet Only display network IDs
|
2016-07-07 14:43:18 -04:00
|
|
|
```
|
2015-09-28 21:57:03 -04:00
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
## Description
|
|
|
|
|
2015-10-18 19:47:32 -04:00
|
|
|
Lists all the networks the Engine `daemon` knows about. This includes the
|
2017-02-07 18:42:48 -05:00
|
|
|
networks that span across multiple hosts in a cluster.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
### List all networks
|
2015-09-28 21:57:03 -04:00
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
|
|
|
$ docker network ls
|
2016-11-09 23:08:15 -05:00
|
|
|
NETWORK ID NAME DRIVER SCOPE
|
|
|
|
7fca4eb8c647 bridge bridge local
|
|
|
|
9f904ee27bf5 none null local
|
|
|
|
cf03ee007fb4 host host local
|
2016-12-08 03:57:27 -05:00
|
|
|
78b03ee04fc4 multi-host overlay swarm
|
2015-10-18 19:47:32 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
Use the `--no-trunc` option to display the full network id:
|
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2016-11-09 23:08:15 -05:00
|
|
|
$ docker network ls --no-trunc
|
|
|
|
NETWORK ID NAME DRIVER SCOPE
|
|
|
|
18a2866682b85619a026c81b98a5e375bd33e1b0936a26cc497c283d27bae9b3 none null local
|
|
|
|
c288470c46f6c8949c5f7e5099b5b7947b07eabe8d9a27d79a9cbf111adcbf47 host host local
|
|
|
|
7b369448dccbf865d397c8d2be0cda7cf7edc6b0945f77d2529912ae917a0185 bridge bridge local
|
|
|
|
95e74588f40db048e86320c6526440c504650a1ff3e9f7d60a497c4d2163e5bd foo bridge local
|
|
|
|
63d1ff1f77b07ca51070a8c227e962238358bd310bde1529cf62e6c307ade161 dev bridge local
|
2015-09-28 21:57:03 -04:00
|
|
|
```
|
2015-10-18 19:47:32 -04:00
|
|
|
|
2023-01-06 13:28:29 -05:00
|
|
|
### <a name="filter"></a> Filtering (--filter)
|
2015-11-10 03:57:06 -05:00
|
|
|
|
|
|
|
The filtering flag (`-f` or `--filter`) format is a `key=value` pair. If there
|
|
|
|
is more than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`).
|
2016-06-28 14:53:39 -04:00
|
|
|
Multiple filter flags are combined as an `OR` filter. For example,
|
2015-11-10 03:57:06 -05:00
|
|
|
`-f type=custom -f type=builtin` returns both `custom` and `builtin` networks.
|
|
|
|
|
|
|
|
The currently supported filters are:
|
|
|
|
|
2016-04-25 16:21:11 -04:00
|
|
|
* driver
|
2015-11-10 03:57:06 -05:00
|
|
|
* id (network's id)
|
2016-03-24 10:31:19 -04:00
|
|
|
* label (`label=<key>` or `label=<key>=<value>`)
|
2015-11-10 03:57:06 -05:00
|
|
|
* name (network's name)
|
2017-03-03 13:45:48 -05:00
|
|
|
* scope (`swarm|global|local`)
|
2017-03-12 15:01:06 -04:00
|
|
|
* type (`custom|builtin`)
|
2015-11-10 03:57:06 -05:00
|
|
|
|
2016-04-25 16:21:11 -04:00
|
|
|
#### Driver
|
|
|
|
|
|
|
|
The `driver` filter matches networks based on their driver.
|
|
|
|
|
|
|
|
The following example matches networks with the `bridge` driver:
|
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2016-04-25 16:21:11 -04:00
|
|
|
$ docker network ls --filter driver=bridge
|
2016-11-09 23:08:15 -05:00
|
|
|
NETWORK ID NAME DRIVER SCOPE
|
|
|
|
db9db329f835 test1 bridge local
|
|
|
|
f6e212da9dfd test2 bridge local
|
2016-04-25 16:21:11 -04:00
|
|
|
```
|
|
|
|
|
2016-03-24 10:31:19 -04:00
|
|
|
#### ID
|
2015-11-10 03:57:06 -05:00
|
|
|
|
2016-03-24 10:31:19 -04:00
|
|
|
The `id` filter matches on all or part of a network's ID.
|
2015-11-10 03:57:06 -05:00
|
|
|
|
2016-03-24 10:31:19 -04:00
|
|
|
The following filter matches all networks with an ID containing the
|
|
|
|
`63d1ff1f77b0...` string.
|
2015-11-10 03:57:06 -05:00
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2016-03-24 10:31:19 -04:00
|
|
|
$ docker network ls --filter id=63d1ff1f77b07ca51070a8c227e962238358bd310bde1529cf62e6c307ade161
|
2016-11-09 23:08:15 -05:00
|
|
|
NETWORK ID NAME DRIVER SCOPE
|
|
|
|
63d1ff1f77b0 dev bridge local
|
2015-11-10 03:57:06 -05:00
|
|
|
```
|
|
|
|
|
2016-03-24 10:31:19 -04:00
|
|
|
You can also filter for a substring in an ID as this shows:
|
2015-11-10 03:57:06 -05:00
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2016-03-24 10:31:19 -04:00
|
|
|
$ docker network ls --filter id=95e74588f40d
|
2016-11-09 23:08:15 -05:00
|
|
|
NETWORK ID NAME DRIVER SCOPE
|
|
|
|
95e74588f40d foo bridge local
|
2016-03-24 10:31:19 -04:00
|
|
|
|
|
|
|
$ docker network ls --filter id=95e
|
2016-11-09 23:08:15 -05:00
|
|
|
NETWORK ID NAME DRIVER SCOPE
|
|
|
|
95e74588f40d foo bridge local
|
2015-11-10 03:57:06 -05:00
|
|
|
```
|
|
|
|
|
2016-03-24 10:31:19 -04:00
|
|
|
#### Label
|
|
|
|
|
2016-04-25 16:21:11 -04:00
|
|
|
The `label` filter matches networks based on the presence of a `label` alone or a `label` and a
|
2016-03-24 10:31:19 -04:00
|
|
|
value.
|
|
|
|
|
|
|
|
The following filter matches networks with the `usage` label regardless of its value.
|
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2016-03-24 10:31:19 -04:00
|
|
|
$ docker network ls -f "label=usage"
|
2016-11-09 23:08:15 -05:00
|
|
|
NETWORK ID NAME DRIVER SCOPE
|
|
|
|
db9db329f835 test1 bridge local
|
|
|
|
f6e212da9dfd test2 bridge local
|
2016-03-24 10:31:19 -04:00
|
|
|
```
|
|
|
|
|
2016-04-25 16:21:11 -04:00
|
|
|
The following filter matches networks with the `usage` label with the `prod` value.
|
2016-03-24 10:31:19 -04:00
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2016-03-24 10:31:19 -04:00
|
|
|
$ docker network ls -f "label=usage=prod"
|
2016-11-09 23:08:15 -05:00
|
|
|
NETWORK ID NAME DRIVER SCOPE
|
|
|
|
f6e212da9dfd test2 bridge local
|
2016-03-24 10:31:19 -04:00
|
|
|
```
|
2015-11-10 03:57:06 -05:00
|
|
|
|
|
|
|
#### Name
|
|
|
|
|
|
|
|
The `name` filter matches on all or part of a network's name.
|
|
|
|
|
|
|
|
The following filter matches all networks with a name containing the `foobar` string.
|
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2015-11-10 03:57:06 -05:00
|
|
|
$ docker network ls --filter name=foobar
|
2016-11-09 23:08:15 -05:00
|
|
|
NETWORK ID NAME DRIVER SCOPE
|
|
|
|
06e7eef0a170 foobar bridge local
|
2015-11-10 03:57:06 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
You can also filter for a substring in a name as this shows:
|
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2016-02-16 22:54:45 -05:00
|
|
|
$ docker network ls --filter name=foo
|
2016-11-09 23:08:15 -05:00
|
|
|
NETWORK ID NAME DRIVER SCOPE
|
|
|
|
95e74588f40d foo bridge local
|
|
|
|
06e7eef0a170 foobar bridge local
|
2015-11-10 03:57:06 -05:00
|
|
|
```
|
|
|
|
|
2017-03-03 13:45:48 -05:00
|
|
|
#### Scope
|
|
|
|
|
|
|
|
The `scope` filter matches networks based on their scope.
|
|
|
|
|
|
|
|
The following example matches networks with the `swarm` scope:
|
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2017-03-03 13:45:48 -05:00
|
|
|
$ docker network ls --filter scope=swarm
|
|
|
|
NETWORK ID NAME DRIVER SCOPE
|
|
|
|
xbtm0v4f1lfh ingress overlay swarm
|
|
|
|
ic6r88twuu92 swarmnet overlay swarm
|
|
|
|
```
|
|
|
|
|
|
|
|
The following example matches networks with the `local` scope:
|
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2017-03-03 13:45:48 -05:00
|
|
|
$ docker network ls --filter scope=local
|
|
|
|
NETWORK ID NAME DRIVER SCOPE
|
|
|
|
e85227439ac7 bridge bridge local
|
|
|
|
0ca0e19443ed host host local
|
|
|
|
ca13cc149a36 localnet bridge local
|
|
|
|
f9e115d2de35 none null local
|
|
|
|
```
|
|
|
|
|
2016-03-24 10:31:19 -04:00
|
|
|
#### Type
|
2015-11-10 03:57:06 -05:00
|
|
|
|
2016-03-24 10:31:19 -04:00
|
|
|
The `type` filter supports two values; `builtin` displays predefined networks
|
|
|
|
(`bridge`, `none`, `host`), whereas `custom` displays user defined networks.
|
2015-11-10 03:57:06 -05:00
|
|
|
|
2016-03-24 10:31:19 -04:00
|
|
|
The following filter matches all user defined networks:
|
2015-11-10 03:57:06 -05:00
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2016-03-24 10:31:19 -04:00
|
|
|
$ docker network ls --filter type=custom
|
2016-11-09 23:08:15 -05:00
|
|
|
NETWORK ID NAME DRIVER SCOPE
|
2020-03-15 10:11:43 -04:00
|
|
|
95e74588f40d foo bridge local
|
2016-11-09 23:08:15 -05:00
|
|
|
63d1ff1f77b0 dev bridge local
|
2015-11-10 03:57:06 -05:00
|
|
|
```
|
|
|
|
|
2016-03-24 10:31:19 -04:00
|
|
|
By having this flag it allows for batch cleanup. For example, use this filter
|
|
|
|
to delete all user defined networks:
|
2015-11-10 03:57:06 -05:00
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2016-03-24 10:31:19 -04:00
|
|
|
$ docker network rm `docker network ls --filter type=custom -q`
|
2015-11-10 03:57:06 -05:00
|
|
|
```
|
2015-10-18 19:47:32 -04:00
|
|
|
|
2016-03-24 10:31:19 -04:00
|
|
|
A warning will be issued when trying to remove a network that has containers
|
|
|
|
attached.
|
|
|
|
|
2023-01-06 13:28:29 -05:00
|
|
|
### <a name="format"></a> Format the output (--format)
|
2016-08-04 08:59:51 -04:00
|
|
|
|
|
|
|
The formatting options (`--format`) pretty-prints networks output
|
|
|
|
using a Go template.
|
|
|
|
|
|
|
|
Valid placeholders for the Go template are listed below:
|
|
|
|
|
2022-03-30 08:33:44 -04:00
|
|
|
| Placeholder | Description |
|
|
|
|
|--------------|----------------------------------------------------------------------------------------|
|
|
|
|
| `.ID` | Network ID |
|
|
|
|
| `.Name` | Network name |
|
|
|
|
| `.Driver` | Network driver |
|
|
|
|
| `.Scope` | Network scope (local, global) |
|
|
|
|
| `.IPv6` | Whether IPv6 is enabled on the network or not. |
|
|
|
|
| `.Internal` | Whether the network is internal or not. |
|
|
|
|
| `.Labels` | All labels assigned to the network. |
|
|
|
|
| `.Label` | Value of a specific label for this network. For example `{{.Label "project.version"}}` |
|
|
|
|
| `.CreatedAt` | Time when the network was created |
|
2016-08-04 08:59:51 -04:00
|
|
|
|
|
|
|
When using the `--format` option, the `network ls` command will either
|
|
|
|
output the data exactly as the template declares or, when using the
|
|
|
|
`table` directive, includes column headers as well.
|
|
|
|
|
|
|
|
The following example uses a template without headers and outputs the
|
2020-04-19 11:23:09 -04:00
|
|
|
`ID` and `Driver` entries separated by a colon (`:`) for all networks:
|
2016-08-04 08:59:51 -04:00
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2016-08-04 08:59:51 -04:00
|
|
|
$ docker network ls --format "{{.ID}}: {{.Driver}}"
|
|
|
|
afaaab448eb2: bridge
|
|
|
|
d1584f8dc718: host
|
|
|
|
391df270dc66: null
|
|
|
|
```
|
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
## Related commands
|
2015-10-18 19:47:32 -04:00
|
|
|
|
|
|
|
* [network disconnect ](network_disconnect.md)
|
|
|
|
* [network connect](network_connect.md)
|
|
|
|
* [network create](network_create.md)
|
|
|
|
* [network inspect](network_inspect.md)
|
|
|
|
* [network rm](network_rm.md)
|
2016-10-18 00:36:52 -04:00
|
|
|
* [network prune](network_prune.md)
|
2016-10-20 23:24:28 -04:00
|
|
|
* [Understand Docker container networks](https://docs.docker.com/engine/userguide/networking/)
|