From 9f64dc98bd68fba0442366027072dbc7c5b45035 Mon Sep 17 00:00:00 2001 From: Wen Cheng Ma Date: Mon, 28 Dec 2015 12:56:57 +0800 Subject: [PATCH] Add Subnets info for user-defined network * If user doesn't specify the subnets to create a network, it will pick subnets from inside preferred pool. This PR aims to inspect these subnets info * Add integration tests for docker inspect the subnets. * docker-py project is already synchronized. * jenkins checks depend on https://github.com/docker/docker-py/pull/888 Fixes issue #18626 Signed-off-by: Wen Cheng Ma --- docs/reference/commandline/network_inspect.md | 28 +++++++++++++++++- man/docker-network-inspect.1.md | 29 ++++++++++++++++++- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/docs/reference/commandline/network_inspect.md b/docs/reference/commandline/network_inspect.md index 00b886d766..9e0d87fa29 100644 --- a/docs/reference/commandline/network_inspect.md +++ b/docs/reference/commandline/network_inspect.md @@ -17,7 +17,7 @@ parent = "smn_cli" -f, --format= Format the output using the given go template. --help Print usage -Returns information about one or more networks. By default, this command renders all results in a JSON object. For example, if you connect two containers to a network: +Returns information about one or more networks. By default, this command renders all results in a JSON object. For example, if you connect two containers to the default `bridge` network: ```bash $ sudo docker run -itd --name=container1 busybox @@ -78,6 +78,32 @@ $ sudo docker network inspect bridge ] ``` +Returns the information about the user-defined network: + +```bash +$ docker network create simple-network +69568e6336d8c96bbf57869030919f7c69524f71183b44d80948bd3927c87f6a +$ docker network inspect simple-network +[ + { + "Name": "simple-network", + "Id": "69568e6336d8c96bbf57869030919f7c69524f71183b44d80948bd3927c87f6a", + "Scope": "local", + "Driver": "bridge", + "IPAM": { + "Driver": "default", + "Config": [ + { + "Subnet": "172.22.0.0/16", + "Gateway": "172.22.0.1/16" + } + ] + }, + "Containers": {}, + "Options": {} + } +] +``` ## Related information diff --git a/man/docker-network-inspect.1.md b/man/docker-network-inspect.1.md index 889967ae85..ceba3688fe 100644 --- a/man/docker-network-inspect.1.md +++ b/man/docker-network-inspect.1.md @@ -12,7 +12,7 @@ NETWORK [NETWORK...] # DESCRIPTION -Returns information about one or more networks. By default, this command renders all results in a JSON object. For example, if you connect two containers to a network: +Returns information about one or more networks. By default, this command renders all results in a JSON object. For example, if you connect two containers to the default `bridge` network: ```bash $ sudo docker run -itd --name=container1 busybox @@ -73,6 +73,33 @@ $ sudo docker network inspect bridge ] ``` +Returns the information about the user-defined network: + +```bash +$ docker network create simple-network +69568e6336d8c96bbf57869030919f7c69524f71183b44d80948bd3927c87f6a +$ docker network inspect simple-network +[ + { + "Name": "simple-network", + "Id": "69568e6336d8c96bbf57869030919f7c69524f71183b44d80948bd3927c87f6a", + "Scope": "local", + "Driver": "bridge", + "IPAM": { + "Driver": "default", + "Config": [ + { + "Subnet": "172.22.0.0/16", + "Gateway": "172.22.0.1/16" + } + ] + }, + "Containers": {}, + "Options": {} + } +] +``` + # OPTIONS **-f**, **--format**="" Format the output using the given go template.