samalba / dockerclient

Docker client library in Go
http://www.docker.com/
Apache License 2.0
320 stars 140 forks source link

Inspecting a Network, doesn't give me the Container ID associated with the network #241

Open bvandewalle opened 8 years ago

bvandewalle commented 8 years ago

When I query the Network and associated Containers on Docker CLI, I get the following:

root@ubuntu:~# docker network inspect b1
[
    {
        "Name": "b1",
        "Id": "52a3537307b177688b2684a5448396e6bcdded9f9e4b9ee9175c7b84fcbb6fe0",
        "Scope": "local",
        "Driver": "nuage",
        "EnableIPv6": false,
        "IPAM": [....],
        "Internal": false,
        "Containers": {
            "9e70c53a64406f3e8e7385e2efb93c7dd14278c8d5163c2c0137f7a80c1ade1c": {
                "Name": "kickass_allen",
                "EndpointID": "8121ce08011b3dc689de821d7eaccb1ff37f0480928d78a9f49c36263d9d8831",
                "MacAddress": "7a:42:3b:2e:a4:bf",
                "IPv4Address": "10.107.54.2/24",
                "IPv6Address": ""
            }
        },
[...]
    }
]

I can get the list of containers associated with that Network. the key for those container is the ID of that container (in this case 9e70c...).

However, when I use this dockerclient lib, the key becomes the Endpoint with an added substring of ep-

map[ep-8121ce08011b3dc689de821d7eaccb1ff37f0480928d78a9f49c36263d9d8831:{kickass_allen 8121ce08011b3dc689de821d7eaccb1ff37f0480928d78a9f49c36263d9d8831 7a:42:3b:2e:a4:bf 10.107.54.2/24 }]

Since I need to report the Container ID, I need to make an extra call to list the containers and match the name to the ID.

Would it be possible to get the container ID as the key when inspecting networks ?

Thanks