方法
docker network inspect [ネットワーク名] -f '{{range .IPAM.Config}}{{.Subnet}}{{end}}'
例
$ docker network inspect afilms_default -f '{{range .IPAM.Config}}{{.Subnet}}{{end}}' 192.168.80.0/20
ネットワーク名を調べる方法
$ docker network ls NETWORK ID NAME DRIVER SCOPE 8dd19b5b834f afilms_default bridge local 7e3ed89b9261 host host local b37e0264e6ff none null local
docker network inspect
docker network inspect [ネットワーク名]
でいろいろな情報をみることができる
json形式で出力される
$ docker network inspect afilms_default [ { "Name": "afilms_default", "Id": "8dd19b5b834fbd9fe9617064aae427bf0ee1e2ca9fda82018c7256306eb0e738", "Created": "2018-05-04T06:33:59.6783397Z", "Scope": "local", "Driver": "bridge", "EnableIPv6": false, "IPAM": { "Driver": "default", "Options": null, "Config": [ { "Subnet": "192.168.80.0/20", "Gateway": "192.168.80.1" } ] }, "Internal": false, "Attachable": true, "Ingress": false, "ConfigFrom": { "Network": "" }, "ConfigOnly": false, "Containers": { "07cffd072b8f66868568e5f5656b5a976b28cfeea7111206f2e405aba74d005b": { "Name": "afilms_app_1", "EndpointID": "51c4e38588fa7148f46a985c1e8b28192b758a6c901f56399afc5607dd3f4a16", "MacAddress": "02:42:c0:a8:50:05", "IPv4Address": "192.168.80.5/20", "IPv6Address": "" }, "093e3bf733e30f5636e4726384e72081bc25854abfb093d6dc1c88991a3347c2": { "Name": "afilms_webpacker_1", "EndpointID": "4b6e62b3217d67b6a2591922ddefc935e2219b742a283b585e6bc2785d2e0ac0", "MacAddress": "02:42:c0:a8:50:02", "IPv4Address": "192.168.80.2/20", "IPv6Address": "" }, "7f3c95cd015a63fe6ca0cc0f5a81fbc8146c5097a6240a097189beea3f60ca2f": { "Name": "afilms_job_1", "EndpointID": "c1782aae5e921fab976fcd07043e41be34fb170cbddec29b11dfb6b6dc77fbef", "MacAddress": "02:42:c0:a8:50:06", "IPv4Address": "192.168.80.6/20", "IPv6Address": "" }, "d26464fada8e638de59e41bd7267e0a1b158c50721c2dd30c5b0358999359fcd": { "Name": "afilms_redis_1", "EndpointID": "d84772758772e0e3e380cd3f22c17b0149fb2eb8cdb5cb4bec8d37e2ba94b611", "MacAddress": "02:42:c0:a8:50:04", "IPv4Address": "192.168.80.4/20", "IPv6Address": "" }, "da052580d9592738586858e620db089fd23e7e8577546450bf259350d134f48f": { "Name": "afilms_db_1", "EndpointID": "78bf286b1701834d36cf262fecf3e54cdec8b1e3e58bc82acdc771699ad7a20d", "MacAddress": "02:42:c0:a8:50:03", "IPv4Address": "192.168.80.3/20", "IPv6Address": "" } }, "Options": {}, "Labels": { "com.docker.compose.network": "default", "com.docker.compose.project": "afilms" } } ]
-f
オプション
-f
オプションをつけることによって出力フォーマットを指定することができる
$ docker network inspect afilms_default -f '{{.Name}}' afilms_default
以上