# Docker Module Improvements/Discussion

**URL:** <https://forum.ansible.com/t/docker-module-improvements-discussion/17443>\
**Category:** Ansible Developer\
**Created:** [February 4, 2015, 12:54pm UTC](https://forum.ansible.com/t/docker-module-improvements-discussion/17443 "2015-02-04T12:54:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Dyball](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@David\_Dyball](https://forum.ansible.com/u/David_Dyball)\
**Post date:** [February 4, 2015, 12:54pm UTC](https://forum.ansible.com/t/docker-module-improvements-discussion/17443/1 "2015-02-04T12:54:01Z")

</div>

Hi All,

I’ve just jumped back on the Ansible train after spending a long time working solely with Docker and noticed a few things I felt were lacking in the Docker module. I’m not the worlds best coder, but I am contemplating a PR to make a few changes to the core docker module or, alternatively, a new ansible-modules-extra addition.

At the moment the current docker module doesn’t seem to make use of all the docker client functionality and, as far as I can tell, is only useful for making sure a container is present/absent/running etc. There doesn’t appear to be a way to perform only one part of the action (e.g. only pull the image, don’t run it). Currently in order to do most tasks I just default back to `command` and run `docker xxxx yyyyy` from there, as I can usually achieve most things that way. I’d love for it to be close to feature-par with the commandline CLI in terms of what you can/can’t do with the module on remote hosts, so here are my thoughts.

a) Make multiple modules for docker (like there currently is for the aws\_\* modules, though I understand it’s not quite the same). Something along the lines of:

docker\_pull Self Explanitory  
docker\_push “”  
docker\_run Wraps docker [create/start/stop/kill/delete] ← pretty much what we already have  
docker\_exec Run ad-hoc commands inside existing containers and return results  
docker\_image Populate a `docker_images` key in system facts  
docker\_tag Self Explanitory  
docker\_inspect Return a dict describing the container/image specified

or …

b) Make each of the above separations sub-commands to a single `docker` module (e.g. `- docker: action=pull target:myimage:latest`). I’m like this one less, but I can see that the `docker_image` module has already been deprecated in favour of a single `docker` module.

So, what are your thoughts and is this something you see as worthwhile?

Cheers,  
David.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [February 5, 2015, 1:49pm UTC](https://forum.ansible.com/t/docker-module-improvements-discussion/17443/2 "2015-02-05T13:49:24Z")

</div>

I think that having separate modules works better, it makes what you  
are doing more apparent and keeps the code smaller and cleaner.

Ansible allows certain modules to share code and documentation, so the  
common parts can still be factored out (see ec2 modules).

---

<div class="post-metadata">

**Author:** ![David\_Dyball](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@David\_Dyball](https://forum.ansible.com/u/David_Dyball)\
**Post date:** [February 5, 2015, 2:12pm UTC](https://forum.ansible.com/t/docker-module-improvements-discussion/17443/3 "2015-02-05T14:12:28Z")

</div>

Hey Brian,

Thanks for the feedback. I think I’m going to go ahead and start working  
on splitting it into separate modules. I’ll see how far I get and submit a  
PR to get some further feedback once I have something to show.

Cheers,  
David.

---

<div class="post-metadata">

**Author:** ![Philip\_Schwartz](https://avatars.discourse-cdn.com/v4/letter/p/a3d4f5/32.png) [@Philip\_Schwartz](https://forum.ansible.com/u/Philip_Schwartz)\
**Post date:** [February 23, 2015, 10:35pm UTC](https://forum.ansible.com/t/docker-module-improvements-discussion/17443/4 "2015-02-23T22:35:08Z")

</div>

David,

Do you have the work you have been doing in a branch on your fork of the repo? If so I will gladly help with parts of this. I have a direct need for docker\_pull so taking what you have and spitting it out and then get features that can be used would be a upfront goal for me.

-Ph

---

<div class="post-metadata">

**Author:** ![David\_Dyball](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@David\_Dyball](https://forum.ansible.com/u/David_Dyball)\
**Post date:** [February 23, 2015, 10:43pm UTC](https://forum.ansible.com/t/docker-module-improvements-discussion/17443/5 "2015-02-23T22:43:08Z")

</div>

Hey Phil,

Yeh I have docker\_pull working and some initial work on docker\_exec, but due to docker-py not yet returning the exit code for exec calls, I haven’t completed that one.

My fork is here: [https://github.com/daviddyball/ansible-modules-extras](https://github.com/daviddyball/ansible-modules-extras)

Gladly accepting any commits.

Cheers,  
Dave
