# restart docker when mounted file changes

**URL:** <https://forum.ansible.com/t/restart-docker-when-mounted-file-changes/20912>\
**Category:** Ansible Project\
**Created:** [March 17, 2016, 11:54pm UTC](https://forum.ansible.com/t/restart-docker-when-mounted-file-changes/20912 "2016-03-17T23:54:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Koen\_Janssens](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Koen\_Janssens](https://forum.ansible.com/u/Koen_Janssens)\
**Post date:** [March 17, 2016, 11:54pm UTC](https://forum.ansible.com/t/restart-docker-when-mounted-file-changes/20912/1 "2016-03-17T23:54:32Z")

</div>

Hi,

I have an ansible tasklist that generates a cfg file from a template first and then starts a docker container using that cfg file as a volume.

Works fine.

But when the generated cfg file changes (cfg file is actually generated from ansible inventory) , the docker container is not restarted, since from docker perspective nothing changed.Is there a way to ‘force’ ansible to restart the container under cetain conditions ?

Thanks,

Koen

Cfg:

---

<div class="post-metadata">

**Author:** ![Uditha\_Desilva](https://avatars.discourse-cdn.com/v4/letter/u/f475e1/32.png) [@Uditha\_Desilva](https://forum.ansible.com/u/Uditha_Desilva)\
**Post date:** [March 19, 2016, 9:40am UTC](https://forum.ansible.com/t/restart-docker-when-mounted-file-changes/20912/2 "2016-03-19T09:40:59Z")

</div>

Changing “state: restarted” (rather than reloaded) might be enough – otherwise try adding a “notify” to the task that is creating the config file, and a “handler” to explicitly stop and then start the container.
