github.com/yogeshlonkar/moby@v1.13.2-0.20201203103638-c0b64beaea94/docs/reference/commandline/network_ls.md (about) 1 --- 2 title: "network ls" 3 description: "The network ls command description and usage" 4 keywords: "network, list, user-defined" 5 --- 6 7 <!-- This file is maintained within the docker/docker Github 8 repository at https://github.com/docker/docker/. Make all 9 pull requests against that repo. If you see this file in 10 another repository, consider it read-only there, as it will 11 periodically be overwritten by the definitive file. Pull 12 requests which include edits to this file in other repositories 13 will be rejected. 14 --> 15 16 # docker network ls 17 18 ```markdown 19 Usage: docker network ls [OPTIONS] 20 21 List networks 22 23 Aliases: 24 ls, list 25 26 Options: 27 -f, --filter filter Provide filter values (e.g. 'driver=bridge') 28 --format string Pretty-print networks using a Go template 29 --help Print usage 30 --no-trunc Do not truncate the output 31 -q, --quiet Only display network IDs 32 ``` 33 34 ## Description 35 36 Lists all the networks the Engine `daemon` knows about. This includes the 37 networks that span across multiple hosts in a cluster. 38 39 ## Examples 40 41 ### List all networks 42 43 ```bash 44 $ sudo docker network ls 45 NETWORK ID NAME DRIVER SCOPE 46 7fca4eb8c647 bridge bridge local 47 9f904ee27bf5 none null local 48 cf03ee007fb4 host host local 49 78b03ee04fc4 multi-host overlay swarm 50 ``` 51 52 Use the `--no-trunc` option to display the full network id: 53 54 ```bash 55 $ docker network ls --no-trunc 56 NETWORK ID NAME DRIVER SCOPE 57 18a2866682b85619a026c81b98a5e375bd33e1b0936a26cc497c283d27bae9b3 none null local 58 c288470c46f6c8949c5f7e5099b5b7947b07eabe8d9a27d79a9cbf111adcbf47 host host local 59 7b369448dccbf865d397c8d2be0cda7cf7edc6b0945f77d2529912ae917a0185 bridge bridge local 60 95e74588f40db048e86320c6526440c504650a1ff3e9f7d60a497c4d2163e5bd foo bridge local 61 63d1ff1f77b07ca51070a8c227e962238358bd310bde1529cf62e6c307ade161 dev bridge local 62 ``` 63 64 ### Filtering 65 66 The filtering flag (`-f` or `--filter`) format is a `key=value` pair. If there 67 is more than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`). 68 Multiple filter flags are combined as an `OR` filter. For example, 69 `-f type=custom -f type=builtin` returns both `custom` and `builtin` networks. 70 71 The currently supported filters are: 72 73 * driver 74 * id (network's id) 75 * label (`label=<key>` or `label=<key>=<value>`) 76 * name (network's name) 77 * type (`custom|builtin`) 78 79 #### Driver 80 81 The `driver` filter matches networks based on their driver. 82 83 The following example matches networks with the `bridge` driver: 84 85 ```bash 86 $ docker network ls --filter driver=bridge 87 NETWORK ID NAME DRIVER SCOPE 88 db9db329f835 test1 bridge local 89 f6e212da9dfd test2 bridge local 90 ``` 91 92 #### ID 93 94 The `id` filter matches on all or part of a network's ID. 95 96 The following filter matches all networks with an ID containing the 97 `63d1ff1f77b0...` string. 98 99 ```bash 100 $ docker network ls --filter id=63d1ff1f77b07ca51070a8c227e962238358bd310bde1529cf62e6c307ade161 101 NETWORK ID NAME DRIVER SCOPE 102 63d1ff1f77b0 dev bridge local 103 ``` 104 105 You can also filter for a substring in an ID as this shows: 106 107 ```bash 108 $ docker network ls --filter id=95e74588f40d 109 NETWORK ID NAME DRIVER SCOPE 110 95e74588f40d foo bridge local 111 112 $ docker network ls --filter id=95e 113 NETWORK ID NAME DRIVER SCOPE 114 95e74588f40d foo bridge local 115 ``` 116 117 #### Label 118 119 The `label` filter matches networks based on the presence of a `label` alone or a `label` and a 120 value. 121 122 The following filter matches networks with the `usage` label regardless of its value. 123 124 ```bash 125 $ docker network ls -f "label=usage" 126 NETWORK ID NAME DRIVER SCOPE 127 db9db329f835 test1 bridge local 128 f6e212da9dfd test2 bridge local 129 ``` 130 131 The following filter matches networks with the `usage` label with the `prod` value. 132 133 ```bash 134 $ docker network ls -f "label=usage=prod" 135 NETWORK ID NAME DRIVER SCOPE 136 f6e212da9dfd test2 bridge local 137 ``` 138 139 #### Name 140 141 The `name` filter matches on all or part of a network's name. 142 143 The following filter matches all networks with a name containing the `foobar` string. 144 145 ```bash 146 $ docker network ls --filter name=foobar 147 NETWORK ID NAME DRIVER SCOPE 148 06e7eef0a170 foobar bridge local 149 ``` 150 151 You can also filter for a substring in a name as this shows: 152 153 ```bash 154 $ docker network ls --filter name=foo 155 NETWORK ID NAME DRIVER SCOPE 156 95e74588f40d foo bridge local 157 06e7eef0a170 foobar bridge local 158 ``` 159 160 #### Type 161 162 The `type` filter supports two values; `builtin` displays predefined networks 163 (`bridge`, `none`, `host`), whereas `custom` displays user defined networks. 164 165 The following filter matches all user defined networks: 166 167 ```bash 168 $ docker network ls --filter type=custom 169 NETWORK ID NAME DRIVER SCOPE 170 95e74588f40d foo bridge local 171 63d1ff1f77b0 dev bridge local 172 ``` 173 174 By having this flag it allows for batch cleanup. For example, use this filter 175 to delete all user defined networks: 176 177 ```bash 178 $ docker network rm `docker network ls --filter type=custom -q` 179 ``` 180 181 A warning will be issued when trying to remove a network that has containers 182 attached. 183 184 ### Formatting 185 186 The formatting options (`--format`) pretty-prints networks output 187 using a Go template. 188 189 Valid placeholders for the Go template are listed below: 190 191 Placeholder | Description 192 ------------|------------------------------------------------------------------------------------------ 193 `.ID` | Network ID 194 `.Name` | Network name 195 `.Driver` | Network driver 196 `.Scope` | Network scope (local, global) 197 `.IPv6` | Whether IPv6 is enabled on the network or not. 198 `.Internal` | Whether the network is internal or not. 199 `.Labels` | All labels assigned to the network. 200 `.Label` | Value of a specific label for this network. For example `{{.Label "project.version"}}` 201 202 When using the `--format` option, the `network ls` command will either 203 output the data exactly as the template declares or, when using the 204 `table` directive, includes column headers as well. 205 206 The following example uses a template without headers and outputs the 207 `ID` and `Driver` entries separated by a colon for all networks: 208 209 ```bash 210 $ docker network ls --format "{{.ID}}: {{.Driver}}" 211 afaaab448eb2: bridge 212 d1584f8dc718: host 213 391df270dc66: null 214 ``` 215 216 ## Related commands 217 218 * [network disconnect ](network_disconnect.md) 219 * [network connect](network_connect.md) 220 * [network create](network_create.md) 221 * [network inspect](network_inspect.md) 222 * [network rm](network_rm.md) 223 * [network prune](network_prune.md) 224 * [Understand Docker container networks](https://docs.docker.com/engine/userguide/networking/)