mirror of https://github.com/docker/docs.git
104 lines
7.8 KiB
YAML
104 lines
7.8 KiB
YAML
command: docker network ls
|
|
aliases: list
|
|
short: List networks
|
|
long: |-
|
|
Lists all the networks the Engine `daemon` knows about. This includes the
|
|
networks that span across multiple hosts in a cluster.
|
|
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
|
|
examples: "### List all networks\n\n```bash\n$ sudo docker network ls\nNETWORK ID
|
|
\ NAME DRIVER SCOPE\n7fca4eb8c647 bridge
|
|
\ bridge local\n9f904ee27bf5 none null
|
|
\ local\ncf03ee007fb4 host host local\n78b03ee04fc4
|
|
\ multi-host overlay swarm\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
|
|
\ SCOPE\n18a2866682b85619a026c81b98a5e375bd33e1b0936a26cc497c283d27bae9b3
|
|
\ none null local\nc288470c46f6c8949c5f7e5099b5b7947b07eabe8d9a27d79a9cbf111adcbf47
|
|
\ host host local\n7b369448dccbf865d397c8d2be0cda7cf7edc6b0945f77d2529912ae917a0185
|
|
\ bridge bridge local\n95e74588f40db048e86320c6526440c504650a1ff3e9f7d60a497c4d2163e5bd
|
|
\ foo bridge local\n63d1ff1f77b07ca51070a8c227e962238358bd310bde1529cf62e6c307ade161
|
|
\ dev bridge local\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* scope (`swarm|global|local`)\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 SCOPE\ndb9db329f835
|
|
\ test1 bridge local\nf6e212da9dfd test2 bridge
|
|
\ local\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 SCOPE\n63d1ff1f77b0 dev
|
|
\ bridge local\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 SCOPE\n95e74588f40d foo bridge
|
|
\ local\n\n$ docker network ls --filter id=95e\nNETWORK ID NAME
|
|
\ DRIVER SCOPE\n95e74588f40d foo bridge
|
|
\ local\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 SCOPE\ndb9db329f835
|
|
\ test1 bridge local\nf6e212da9dfd test2 bridge
|
|
\ local\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 SCOPE\nf6e212da9dfd test2 bridge
|
|
\ local\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 SCOPE\n06e7eef0a170 foobar bridge
|
|
\ local\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
|
|
\ SCOPE\n95e74588f40d foo bridge local\n06e7eef0a170
|
|
\ foobar bridge local\n```\n\n#### Scope\n\nThe `scope`
|
|
filter matches networks based on their scope.\n\nThe following example matches networks
|
|
with the `swarm` scope:\n\n```bash\n$ docker network ls --filter scope=swarm\nNETWORK
|
|
ID NAME DRIVER SCOPE\nxbtm0v4f1lfh ingress
|
|
\ overlay swarm\nic6r88twuu92 swarmnet overlay
|
|
\ swarm\n```\n\nThe following example matches networks with the `local`
|
|
scope:\n\n```bash\n$ docker network ls --filter scope=local\nNETWORK ID NAME
|
|
\ DRIVER SCOPE\ne85227439ac7 bridge bridge
|
|
\ local\n0ca0e19443ed host host local\nca13cc149a36
|
|
\ localnet bridge local\nf9e115d2de35 none
|
|
\ null local\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 SCOPE\n95e74588f40d foo bridge
|
|
\ local \n63d1ff1f77b0 dev bridge local\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### Formatting\n\nThe formatting options (`--format`)
|
|
pretty-prints networks output\nusing a Go template.\n\nValid placeholders for the
|
|
Go template are listed below:\n\nPlaceholder | Description\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`.CreatedAt` | Time
|
|
when the network was created\n\nWhen using the `--format` option, the `network ls`
|
|
command will either\noutput the data exactly as the template declares or, when using
|
|
the\n`table` directive, includes column headers as well.\n\nThe following example
|
|
uses a template without headers and outputs the\n`ID` and `Driver` entries separated
|
|
by a colon for all networks:\n\n```bash\n$ docker network ls --format \"{{.ID}}:
|
|
{{.Driver}}\"\nafaaab448eb2: bridge\nd1584f8dc718: host\n391df270dc66: null\n```"
|
|
|