saltstack/salt — pull request #16918 by krak3n (2014-10-28 09:36:09+00:00)
Title: dockerio.get_containers optional call to dockerio._get_container_infos

Hi Guys

I've been thinking about how Salt could better utilise docker. One of dockers strengths is you can run as many containers of the same image as you require. However Salt has very limited capability when it comes to getting information about running containers.

One limitation I've found is mining information about containers that do not have published ports: https://github.com/saltstack/salt/blob/develop/salt/modules/mine.py#L350 will raise a KeyError in the event you haven't run your container with `-p 0.0.0.0:5000:5000` for example.

Another limitation is the amount of information `modules.dockerio.get_containers` returns, its basically the information gathered from `docker ps` which is great but what if I want to mine more information about my containers? The volumes shared, the ports exposed, the private IP of the container itself, you can't which I think would be extremely useful.

To that end a propose adding an `inspect` option to the `dockerio.modules.get_containers` method (`False` by default) which for each container will call `_get_container_infos` which basically runs a `docker inspect `. This would give us the option of mining much more granular and useful data about our running containers.

I have a working prototype and If you guys think this is worth while I'll get a PR in on this issue :smile:

Thanks,

Chris