mirror of https://github.com/docker/docs.git
79 lines
5.7 KiB
YAML
79 lines
5.7 KiB
YAML
command: docker network ls
|
|
short: List networks
|
|
long: "Lists all the networks the Engine `daemon` knows about. This includes the\nnetworks
|
|
that span across multiple hosts in a cluster, for example:\n\n```bash\n $ docker
|
|
network ls\n NETWORK ID NAME DRIVER\n 7fca4eb8c647
|
|
\ bridge bridge\n 9f904ee27bf5 none null\n
|
|
\ cf03ee007fb4 host host\n 78b03ee04fc4 multi-host
|
|
\ overlay\n```\n\nUse the `--no-trunc` option to display the full network
|
|
id:\n\n```bash\n$ docker network ls --no-trunc\nNETWORK ID NAME
|
|
\ DRIVER\n18a2866682b85619a026c81b98a5e375bd33e1b0936a26cc497c283d27bae9b3
|
|
\ none null \nc288470c46f6c8949c5f7e5099b5b7947b07eabe8d9a27d79a9cbf111adcbf47
|
|
\ host host \n7b369448dccbf865d397c8d2be0cda7cf7edc6b0945f77d2529912ae917a0185
|
|
\ bridge bridge \n95e74588f40db048e86320c6526440c504650a1ff3e9f7d60a497c4d2163e5bd
|
|
\ foo bridge \n63d1ff1f77b07ca51070a8c227e962238358bd310bde1529cf62e6c307ade161
|
|
\ dev bridge\n```\n\n## Filtering\n\nThe filtering flag (`-f` or
|
|
`--filter`) format is a `key=value` pair. If there\nis more than one filter, then
|
|
pass multiple flags (e.g. `--filter \"foo=bar\" --filter \"bif=baz\"`).\nMultiple
|
|
filter flags are combined as an `OR` filter. For example, \n`-f type=custom -f type=builtin`
|
|
returns both `custom` and `builtin` networks.\n\nThe currently supported filters
|
|
are:\n\n* driver\n* id (network's id)\n* label (`label=<key>` or `label=<key>=<value>`)\n*
|
|
name (network's name)\n* type (custom|builtin)\n\n#### Driver\n\nThe `driver` filter
|
|
matches networks based on their driver.\n\nThe following example matches networks
|
|
with the `bridge` driver:\n\n```bash\n$ docker network ls --filter driver=bridge\nNETWORK
|
|
ID NAME DRIVER\ndb9db329f835 test1 bridge\nf6e212da9dfd
|
|
\ test2 bridge\n```\n\n#### ID\n\nThe `id` filter matches on
|
|
all or part of a network's ID.\n\nThe following filter matches all networks with
|
|
an ID containing the\n`63d1ff1f77b0...` string.\n\n```bash\n$ docker network ls
|
|
--filter id=63d1ff1f77b07ca51070a8c227e962238358bd310bde1529cf62e6c307ade161\nNETWORK
|
|
ID NAME DRIVER\n63d1ff1f77b0 dev bridge\n```\n\nYou
|
|
can also filter for a substring in an ID as this shows:\n\n```bash\n$ docker network
|
|
ls --filter id=95e74588f40d\nNETWORK ID NAME DRIVER\n95e74588f40d
|
|
\ foo bridge\n\n$ docker network ls --filter id=95e\nNETWORK
|
|
ID NAME DRIVER\n95e74588f40d foo bridge\n```\n\n####
|
|
Label\n\nThe `label` filter matches networks based on the presence of a `label`
|
|
alone or a `label` and a\nvalue.\n\nThe following filter matches networks with the
|
|
`usage` label regardless of its value.\n\n```bash\n$ docker network ls -f \"label=usage\"\nNETWORK
|
|
ID NAME DRIVER\ndb9db329f835 test1 bridge
|
|
\ \nf6e212da9dfd test2 bridge\n```\n\nThe following
|
|
filter matches networks with the `usage` label with the `prod` value.\n\n```bash\n$
|
|
docker network ls -f \"label=usage=prod\"\nNETWORK ID NAME DRIVER\nf6e212da9dfd
|
|
\ test2 bridge\n```\n\n#### Name\n\nThe `name` filter matches
|
|
on all or part of a network's name.\n\nThe following filter matches all networks
|
|
with a name containing the `foobar` string.\n\n```bash\n$ docker network ls --filter
|
|
name=foobar\nNETWORK ID NAME DRIVER\n06e7eef0a170 foobar
|
|
\ bridge\n```\n\nYou can also filter for a substring in a name as this
|
|
shows:\n\n```bash\n$ docker network ls --filter name=foo\nNETWORK ID NAME
|
|
\ DRIVER\n95e74588f40d foo bridge\n06e7eef0a170
|
|
\ foobar bridge\n```\n\n#### Type\n\nThe `type` filter supports
|
|
two values; `builtin` displays predefined networks\n(`bridge`, `none`, `host`),
|
|
whereas `custom` displays user defined networks.\n\nThe following filter matches
|
|
all user defined networks:\n\n```bash\n$ docker network ls --filter type=custom\nNETWORK
|
|
ID NAME DRIVER\n95e74588f40d foo bridge\n63d1ff1f77b0
|
|
\ dev bridge\n```\n\nBy having this flag it allows for batch
|
|
cleanup. For example, use this filter\nto delete all user defined networks:\n\n```bash\n$
|
|
docker network rm `docker network ls --filter type=custom -q`\n```\n\nA warning
|
|
will be issued when trying to remove a network that has containers\nattached.\n\n##
|
|
Format\n\nFormat uses a Go template to print the output. The following variables
|
|
are \nsupported: \n\n* .ID - Network ID\n* .Name - Network name\n* .Driver - Network
|
|
driver\n* .Scope - Network scope (local, global)\n* .IPv6 - Whether IPv6 is enabled
|
|
on the network or not\n* .Internal - Whether the network is internal or not\n* .Labels
|
|
- All labels assigned to the network\n* .Label - Value of a specific label for this
|
|
network. For example `{{.Label \"project.version\"}}`\n"
|
|
usage: docker network ls [OPTIONS]
|
|
pname: docker network
|
|
plink: docker_network.yaml
|
|
options:
|
|
- option: filter
|
|
shorthand: f
|
|
description: Provide filter values (e.g. 'driver=bridge')
|
|
- option: format
|
|
description: Pretty-print networks using a Go template
|
|
- option: no-trunc
|
|
default_value: "false"
|
|
description: Do not truncate the output
|
|
- option: quiet
|
|
shorthand: q
|
|
default_value: "false"
|
|
description: Only display network IDs
|