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