Docker module does not restart containers when docker parameters have changed

Currently the docker module only restarts the container if the name parameter is specified and the image has changed. Are there plans to also check if other docker parameters have changed such as env, port and volume?
It is pretty common to pass in configuration information via environment variables to containers. It would be nice if the Ansible docker modules realizes docker parameters have changed, then automatically restart the container.
I don’t think volume or port will change often but configuration information via environment variables will certainly evolve over time.

Aaron

There are no plans per se but that doesn’t mean it’s not a good idea.

I think it would depend on whether this was easily queryable by docker-py, but I imagine it would be.

If you’d like to work on this, you are welcome, otherwise please file a feature request in GitHub so we don’t lose track of the idea.

Thanks!

Here’s the code change to restart the container if env vars have changed:

https://github.com/forty9ten/ansible-modules-core/compare/ansible:devel...devel

Let me know what you think.

I know in the previous post I also talked about also checking other parameters such as volume and port.
Maybe that can be done as a separate PR. I believe just the environmental detection is useful on its own.

Aaron

Hi Aron,

Hi Vasco,

Does that mean you do not experience
https://github.com/ansible/ansible-modules-core/issues/27 ?

The issue I'm trying to tackle is slightly different than yours. My
image:tag has not changed (ie, not using latest but actual version
tag) but some other Docker parameters have changed within Ansible
playbook. The code patch above only currently handles environment
variables, but I plan to also handle port and volumes sometime today.

The issue you reference is also what I have been seeing, but it is not
an issue for me because the tag and image are being changed at the
same time.

Aaron

Just a note - please send in a PR if you have something, if you just send me the diff on your branch and master, we won’t have it in the list.

Understood. I’m still working on it. I will definitely send PR when I am ready.

Aaron