Browse code

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 <madhu@docker.com>

Madhu Venugopal authored on 2016/03/13 06:29:25
Showing 2 changed files
... ...
@@ -174,11 +174,12 @@ func buildNetworkResource(nw libnetwork.Network) *types.NetworkResource {
174 174
 			continue
175 175
 		}
176 176
 		sb := ei.Sandbox()
177
-		if sb == nil {
178
-			continue
177
+		key := "ep-" + e.ID()
178
+		if sb != nil {
179
+			key = sb.ContainerID()
179 180
 		}
180 181
 
181
-		r.Containers[sb.ContainerID()] = buildEndpointResource(e)
182
+		r.Containers[key] = buildEndpointResource(e)
182 183
 	}
183 184
 	return r
184 185
 }
... ...
@@ -28,7 +28,10 @@ bda12f8922785d1f160be70736f26c1e331ab8aaf8ed8d56728508f2e2fd4727
28 28
 ```
29 29
 
30 30
 The `network inspect` command shows the containers, by id, in its
31
-results. You can specify an alternate format to execute a given
31
+results. For networks backed by multi-host network driver, such as Overlay,
32
+this command also shows the container endpoints in other hosts in the
33
+cluster. These endpoints are represented as "ep-{endpoint-id}" in the output.
34
+You can specify an alternate format to execute a given
32 35
 template for each result. Go's
33 36
 [text/template](http://golang.org/pkg/text/template/) package describes all the
34 37
 details of the format.