XDATA-Year-3 / geoapp

XData GeoApp
Apache License 2.0
7 stars 2 forks source link

Update demo script to retrieve Docker IPs by network name #226

Closed danlamanna closed 8 years ago

danlamanna commented 8 years ago

@manthey Lazily copying my PR text from demodock to here:

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.

manthey commented 8 years ago

LGTM. I'll note that this needs a recent version of docker-py to work, too.