mirror of
https://github.com/moby/moby.git
synced 2025-08-01 05:47:11 +03:00
Add containers’ networks to /containers/json
After addition of multi-host networking in Docker 1.9, Docker Remote API is still returning only the network specified during creation of the container in the “List Containers” (`/containers/json`) endpoint: ... "HostConfig": { "NetworkMode": "default" }, The list of networks containers are attached to is only available at Get Container (`/containers/<id>/json`) endpoint. This does not allow applications utilizing multi-host networking to be built on top of Docker Remote API. Therefore I added a simple `"NetworkSettings"` section to the `/containers/json` endpoint. This is not identical to the NetworkSettings returned in Get Container (`/containers/<id>/json`) endpoint. It only contains a single field `"Networks"`, which is essentially the same value shown in inspect output of a container. This change adds the following section to the `/containers/json`: "NetworkSettings": { "Networks": { "bridge": { "EndpointID": "2cdc4edb1ded3631c81f57966563e...", "Gateway": "172.17.0.1", "IPAddress": "172.17.0.2", "IPPrefixLen": 16, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "02:42:ac:11:00:02" } } } This is of type `SummaryNetworkSettings` type, a minimal version of `api/types#NetworkSettings`. Actually all I need is the network name and the IPAddress fields. If folks find this addition too big, I can create a `SummaryEndpointSettings` field as well, containing just the IPAddress field. Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
This commit is contained in:
@ -68,6 +68,7 @@ func (s *DockerSuite) TestContainerApiGetJSONNoFieldsOmitted(c *check.C) {
|
||||
"Ports",
|
||||
"Labels",
|
||||
"Status",
|
||||
"NetworkSettings",
|
||||
}
|
||||
|
||||
// decoding into types.Container do not work since it eventually unmarshal
|
||||
|
Reference in New Issue
Block a user