github.com/AliyunContainerService/cli@v0.0.0-20181009023821-814ced4b30d0/docs/reference/commandline/network_inspect.md (about) 1 --- 2 title: "network inspect" 3 description: "The network inspect command description and usage" 4 keywords: "network, inspect, user-defined" 5 --- 6 7 <!-- This file is maintained within the docker/cli GitHub 8 repository at https://github.com/docker/cli/. 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 # network inspect 17 18 ```markdown 19 Usage: docker network inspect [OPTIONS] NETWORK [NETWORK...] 20 21 Display detailed information on one or more networks 22 23 Options: 24 -f, --format string Format the output using the given Go template 25 --help Print usage 26 ``` 27 28 ## Description 29 30 Returns information about one or more networks. By default, this command renders 31 all results in a JSON object. 32 33 ## Examples 34 35 ## Inspect the `bridge` network 36 37 Connect two containers to the default `bridge` network: 38 39 ```bash 40 $ sudo docker run -itd --name=container1 busybox 41 f2870c98fd504370fb86e59f32cd0753b1ac9b69b7d80566ffc7192a82b3ed27 42 43 $ sudo docker run -itd --name=container2 busybox 44 bda12f8922785d1f160be70736f26c1e331ab8aaf8ed8d56728508f2e2fd4727 45 ``` 46 47 The `network inspect` command shows the containers, by id, in its 48 results. For networks backed by multi-host network driver, such as Overlay, 49 this command also shows the container endpoints in other hosts in the 50 cluster. These endpoints are represented as "ep-{endpoint-id}" in the output. 51 However, for swarm mode networks, only the endpoints that are local to the 52 node are shown. 53 54 You can specify an alternate format to execute a given 55 template for each result. Go's 56 [text/template](http://golang.org/pkg/text/template/) package describes all the 57 details of the format. 58 59 ```none 60 $ sudo docker network inspect bridge 61 62 [ 63 { 64 "Name": "bridge", 65 "Id": "b2b1a2cba717161d984383fd68218cf70bbbd17d328496885f7c921333228b0f", 66 "Created": "2016-10-19T04:33:30.360899459Z", 67 "Scope": "local", 68 "Driver": "bridge", 69 "IPAM": { 70 "Driver": "default", 71 "Config": [ 72 { 73 "Subnet": "172.17.42.1/16", 74 "Gateway": "172.17.42.1" 75 } 76 ] 77 }, 78 "Internal": false, 79 "Containers": { 80 "bda12f8922785d1f160be70736f26c1e331ab8aaf8ed8d56728508f2e2fd4727": { 81 "Name": "container2", 82 "EndpointID": "0aebb8fcd2b282abe1365979536f21ee4ceaf3ed56177c628eae9f706e00e019", 83 "MacAddress": "02:42:ac:11:00:02", 84 "IPv4Address": "172.17.0.2/16", 85 "IPv6Address": "" 86 }, 87 "f2870c98fd504370fb86e59f32cd0753b1ac9b69b7d80566ffc7192a82b3ed27": { 88 "Name": "container1", 89 "EndpointID": "a00676d9c91a96bbe5bcfb34f705387a33d7cc365bac1a29e4e9728df92d10ad", 90 "MacAddress": "02:42:ac:11:00:01", 91 "IPv4Address": "172.17.0.1/16", 92 "IPv6Address": "" 93 } 94 }, 95 "Options": { 96 "com.docker.network.bridge.default_bridge": "true", 97 "com.docker.network.bridge.enable_icc": "true", 98 "com.docker.network.bridge.enable_ip_masquerade": "true", 99 "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0", 100 "com.docker.network.bridge.name": "docker0", 101 "com.docker.network.driver.mtu": "1500" 102 }, 103 "Labels": {} 104 } 105 ] 106 ``` 107 108 ### Inspect a user-defined network 109 110 Create and inspect a user-defined network: 111 112 ```bash 113 $ docker network create simple-network 114 115 69568e6336d8c96bbf57869030919f7c69524f71183b44d80948bd3927c87f6a 116 ``` 117 118 ```none 119 $ docker network inspect simple-network 120 121 [ 122 { 123 "Name": "simple-network", 124 "Id": "69568e6336d8c96bbf57869030919f7c69524f71183b44d80948bd3927c87f6a", 125 "Created": "2016-10-19T04:33:30.360899459Z", 126 "Scope": "local", 127 "Driver": "bridge", 128 "IPAM": { 129 "Driver": "default", 130 "Config": [ 131 { 132 "Subnet": "172.22.0.0/16", 133 "Gateway": "172.22.0.1" 134 } 135 ] 136 }, 137 "Containers": {}, 138 "Options": {}, 139 "Labels": {} 140 } 141 ] 142 ``` 143 144 ### Inspect the `ingress` network 145 146 For swarm mode overlay networks `network inspect` also shows the IP address and node name 147 of the peers. Peers are the nodes in the swarm cluster which have at least one task attached 148 to the network. Node name is of the format `<hostname>-<unique ID>`. 149 150 ```none 151 $ docker network inspect ingress 152 153 [ 154 { 155 "Name": "ingress", 156 "Id": "j0izitrut30h975vk4m1u5kk3", 157 "Created": "2016-11-08T06:49:59.803387552Z", 158 "Scope": "swarm", 159 "Driver": "overlay", 160 "EnableIPv6": false, 161 "IPAM": { 162 "Driver": "default", 163 "Options": null, 164 "Config": [ 165 { 166 "Subnet": "10.255.0.0/16", 167 "Gateway": "10.255.0.1" 168 } 169 ] 170 }, 171 "Internal": false, 172 "Attachable": false, 173 "Containers": { 174 "ingress-sbox": { 175 "Name": "ingress-endpoint", 176 "EndpointID": "40e002d27b7e5d75f60bc72199d8cae3344e1896abec5eddae9743755fe09115", 177 "MacAddress": "02:42:0a:ff:00:03", 178 "IPv4Address": "10.255.0.3/16", 179 "IPv6Address": "" 180 } 181 }, 182 "Options": { 183 "com.docker.network.driver.overlay.vxlanid_list": "256" 184 }, 185 "Labels": {}, 186 "Peers": [ 187 { 188 "Name": "net-1-1d22adfe4d5c", 189 "IP": "192.168.33.11" 190 }, 191 { 192 "Name": "net-2-d55d838b34af", 193 "IP": "192.168.33.12" 194 }, 195 { 196 "Name": "net-3-8473f8140bd9", 197 "IP": "192.168.33.13" 198 } 199 ] 200 } 201 ] 202 ``` 203 204 ### Using `verbose` option for `network inspect` 205 206 `docker network inspect --verbose` for swarm mode overlay networks shows service-specific 207 details such as the service's VIP and port mappings. It also shows IPs of service tasks, 208 and the IPs of the nodes where the tasks are running. 209 210 Following is an example output for an overlay network `ov1` that has one service `s1` 211 attached to. service `s1` in this case has three replicas. 212 213 ```bash 214 $ docker network inspect --verbose ov1 215 [ 216 { 217 "Name": "ov1", 218 "Id": "ybmyjvao9vtzy3oorxbssj13b", 219 "Created": "2017-03-13T17:04:39.776106792Z", 220 "Scope": "swarm", 221 "Driver": "overlay", 222 "EnableIPv6": false, 223 "IPAM": { 224 "Driver": "default", 225 "Options": null, 226 "Config": [ 227 { 228 "Subnet": "10.0.0.0/24", 229 "Gateway": "10.0.0.1" 230 } 231 ] 232 }, 233 "Internal": false, 234 "Attachable": false, 235 "Containers": { 236 "020403bd88a15f60747fd25d1ad5fa1272eb740e8a97fc547d8ad07b2f721c5e": { 237 "Name": "s1.1.pjn2ik0sfgkfzed3h0s00gs9o", 238 "EndpointID": "ad16946f416562d658f3bb30b9830d73ad91ccf6feae44411269cd0ff674714e", 239 "MacAddress": "02:42:0a:00:00:04", 240 "IPv4Address": "10.0.0.4/24", 241 "IPv6Address": "" 242 } 243 }, 244 "Options": { 245 "com.docker.network.driver.overlay.vxlanid_list": "4097" 246 }, 247 "Labels": {}, 248 "Peers": [ 249 { 250 "Name": "net-3-5d3cfd30a58c", 251 "IP": "192.168.33.13" 252 }, 253 { 254 "Name": "net-1-6ecbc0040a73", 255 "IP": "192.168.33.11" 256 }, 257 { 258 "Name": "net-2-fb80208efd75", 259 "IP": "192.168.33.12" 260 } 261 ], 262 "Services": { 263 "s1": { 264 "VIP": "10.0.0.2", 265 "Ports": [], 266 "LocalLBIndex": 257, 267 "Tasks": [ 268 { 269 "Name": "s1.2.q4hcq2aiiml25ubtrtg4q1txt", 270 "EndpointID": "040879b027e55fb658e8b60ae3b87c6cdac7d291e86a190a3b5ac6567b26511a", 271 "EndpointIP": "10.0.0.5", 272 "Info": { 273 "Host IP": "192.168.33.11" 274 } 275 }, 276 { 277 "Name": "s1.3.yawl4cgkp7imkfx469kn9j6lm", 278 "EndpointID": "106edff9f120efe44068b834e1cddb5b39dd4a3af70211378b2f7a9e562bbad8", 279 "EndpointIP": "10.0.0.3", 280 "Info": { 281 "Host IP": "192.168.33.12" 282 } 283 }, 284 { 285 "Name": "s1.1.pjn2ik0sfgkfzed3h0s00gs9o", 286 "EndpointID": "ad16946f416562d658f3bb30b9830d73ad91ccf6feae44411269cd0ff674714e", 287 "EndpointIP": "10.0.0.4", 288 "Info": { 289 "Host IP": "192.168.33.13" 290 } 291 } 292 ] 293 } 294 } 295 } 296 ] 297 ``` 298 299 ## Related commands 300 301 * [network disconnect ](network_disconnect.md) 302 * [network connect](network_connect.md) 303 * [network create](network_create.md) 304 * [network ls](network_ls.md) 305 * [network rm](network_rm.md) 306 * [network prune](network_prune.md) 307 * [Understand Docker container networks](https://docs.docker.com/engine/userguide/networking/)