# Restart Docker Container By Name?

**URL:** <https://forum.ansible.com/t/restart-docker-container-by-name/16147>\
**Category:** Ansible Project\
**Created:** [September 8, 2014, 3:15pm UTC](https://forum.ansible.com/t/restart-docker-container-by-name/16147 "2014-09-08T15:15:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_Hughes](https://avatars.discourse-cdn.com/v4/letter/m/f04885/32.png) [@Matt\_Hughes](https://forum.ansible.com/u/Matt_Hughes)\
**Post date:** [September 8, 2014, 3:15pm UTC](https://forum.ansible.com/t/restart-docker-container-by-name/16147/1 "2014-09-08T15:15:15Z")

</div>

Using the docker module in the master branch. I have one task that ensures a particular docker container is running with a given name. And then I have a handler that tries to restart that container (by name) when any configuration changes.

However, it looks like the docker module requires you to specify the parameters all over again. IMO, you should be able to say:

name: Restart a Container  
docker: name=“existing\_container” state=“restarted”

but instead, I have to respecify all my docker parameters in the handler:

name: Restart a Container  
docker: name=“existing\_container” state=“restarted” ports=“…” volumes=“…”

I would think we support the first form and the command just fails if there isn’t an existing container with that name. Thoughts?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [September 8, 2014, 9:40pm UTC](https://forum.ansible.com/t/restart-docker-container-by-name/16147/2 "2014-09-08T21:40:49Z")

</div>

I’d concur.

Can you share what version of Ansible you are using? (ansible --version) and also paste the output when you leave them off?

---

<div class="post-metadata">

**Author:** ![Matt\_Hughes](https://avatars.discourse-cdn.com/v4/letter/m/f04885/32.png) [@Matt\_Hughes](https://forum.ansible.com/u/Matt_Hughes)\
**Post date:** [September 23, 2014, 5:34pm UTC](https://forum.ansible.com/t/restart-docker-container-by-name/16147/3 "2014-09-23T17:34:51Z")

</div>

Ansible 1.8 (devel c289ba1b21) last updated 2014/09/22 14:24:43 (GMT -400)
