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