Docker module required arguments - should image always be mandatory?

Hi there. I’m fairly certain the docker module is working as designed, but I wanted to make sure before I create an issue on github.

- name: stop docker container
  docker:
    name=myapp
    image=myappimage
    state=absent

I was poking around the docker.py code, and it seems like it's just "image = module.params.get('image')" that's doing it. 

But really, the image param shouldn't be required for every state. Right? Thanks!


--dave




Hi, Dave.

That’s a good point.

Really, all that you need to specify is a way to uniquely identify the set of containers that you want the task to operate on. This is either:

  1. name, OR
  2. image, plus optional command.

If you’re using a state that could create a new container, then the image is required so that Docker knows what image to use, but for state=stopped, state=killed or state=absent, we shouldn’t require image if you’ve already specified a name. In fact, I think it’s ignored in those cases, so you can pass it a garbage value and no behavior will change.

A GitHub issue sounds like a good idea.

  • Ash