Skip to content

WIP: Use Docker Networks to retrieve IP Addresses

@ronichoudhury

I haven't tested this yet, but this is basically a description of the issue:

The IP address has traditionally been accessed through /NetworkSettings/IPAddress. Docker 1.8 introduced docker networks which provides access to the network(s) a container is a part of and their IP addresses at /NetworkSettings/Networks/$network/IPAddress where $network is /HostConfig/NetworkMode.

In my small amount of testing, NetworkMode was always set (defaulting to bridge) and the Networks array was present. So this method should supplant the original cleanly, however I wasn't able to find any formal documentation denoting the existence of keys in the inspect output.

Docker also has the ability to have a container associated with multiple networks, in which case I'm not sure how this code will function. Ideally we would inspect how docker-machine ip handles cases such as these.

Merge request reports

Loading