From f960c0a25f1d950c7f7f2c33edb6e35fb10d06dd Mon Sep 17 00:00:00 2001 From: Madhu Venugopal Date: Sat, 12 Mar 2016 13:29:25 -0800 Subject: [PATCH] Include all endpoints in network inspect object Prior to this change, the "docker network inspect" contains only the endpoints that have active local container. This excludes all the remote and stale endpoints. By including all the endpoints, it makes debugging much simpler and also allows the user to cleanup any stale endpoints using "docker network disconnect -f {network} {endpoint-name}". Signed-off-by: Madhu Venugopal Upstream-commit: 2ef00ba89fc04b0a7571aa050d8a11c06f758d9b Component: engine --- .../engine/api/server/router/network/network_routes.go | 7 ++++--- .../engine/docs/reference/commandline/network_inspect.md | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/components/engine/api/server/router/network/network_routes.go b/components/engine/api/server/router/network/network_routes.go index 851a10cb89..3460a03b2c 100644 --- a/components/engine/api/server/router/network/network_routes.go +++ b/components/engine/api/server/router/network/network_routes.go @@ -174,11 +174,12 @@ func buildNetworkResource(nw libnetwork.Network) *types.NetworkResource { continue } sb := ei.Sandbox() - if sb == nil { - continue + key := "ep-" + e.ID() + if sb != nil { + key = sb.ContainerID() } - r.Containers[sb.ContainerID()] = buildEndpointResource(e) + r.Containers[key] = buildEndpointResource(e) } return r } diff --git a/components/engine/docs/reference/commandline/network_inspect.md b/components/engine/docs/reference/commandline/network_inspect.md index 84478d9cee..251407e596 100644 --- a/components/engine/docs/reference/commandline/network_inspect.md +++ b/components/engine/docs/reference/commandline/network_inspect.md @@ -28,7 +28,10 @@ bda12f8922785d1f160be70736f26c1e331ab8aaf8ed8d56728508f2e2fd4727 ``` The `network inspect` command shows the containers, by id, in its -results. You can specify an alternate format to execute a given +results. For networks backed by multi-host network driver, such as Overlay, +this command also shows the container endpoints in other hosts in the +cluster. These endpoints are represented as "ep-{endpoint-id}" in the output. +You can specify an alternate format to execute a given template for each result. Go's [text/template](http://golang.org/pkg/text/template/) package describes all the details of the format.