Docker module does not restart containers when docker parameters have changed

200 views
Skip to first unread message

Aaron Feng

unread,
Sep 24, 2014, 12:11:37 PM9/24/14
to ansible...@googlegroups.com
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

Michael DeHaan

unread,
Sep 24, 2014, 12:17:11 PM9/24/14
to ansible...@googlegroups.com
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!




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d9292738-d214-4a7e-98ef-c5e40e37d57b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aaron Feng

unread,
Oct 1, 2014, 12:32:30 PM10/1/14
to ansible...@googlegroups.com
Here's the code change to restart the container if env vars have changed:


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

Vasco Figueira

unread,
Oct 2, 2014, 7:17:22 AM10/2/14
to ansible...@googlegroups.com
Hi Aron,

On Wednesday, 24 September 2014 17:11:37 UTC+1, Aaron Feng wrote:
Currently the docker module only restarts the container if the name parameter is specified and the image has changed.

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

Thanks 

Aaron Feng

unread,
Oct 2, 2014, 8:39:57 AM10/2/14
to ansible...@googlegroups.com
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

Michael DeHaan

unread,
Oct 2, 2014, 4:51:51 PM10/2/14
to ansible...@googlegroups.com
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.




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

Aaron Feng

unread,
Oct 2, 2014, 5:54:07 PM10/2/14
to ansible...@googlegroups.com
Understood. I'm still working on it. I will definitely send PR when I am ready. 

Aaron 
Reply all
Reply to author
Forward
0 new messages