# How can i specify --rm with Docker run command to make sure the containers are cleaned up on exit ?

**URL:** <https://forum.ansible.com/t/how-can-i-specify-rm-with-docker-run-command-to-make-sure-the-containers-are-cleaned-up-on-exit/21030>\
**Category:** Ansible Project\
**Created:** [March 31, 2016, 5:25am UTC](https://forum.ansible.com/t/how-can-i-specify-rm-with-docker-run-command-to-make-sure-the-containers-are-cleaned-up-on-exit/21030 "2016-03-31T05:25:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ishan\_jain](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@ishan\_jain](https://forum.ansible.com/u/ishan_jain)\
**Post date:** [March 31, 2016, 5:25am UTC](https://forum.ansible.com/t/how-can-i-specify-rm-with-docker-run-command-to-make-sure-the-containers-are-cleaned-up-on-exit/21030/1 "2016-03-31T05:25:12Z")

</div>

As per the Docker docs for Docker run - [https://docs.docker.com/engine/reference/run/](https://docs.docker.com/engine/reference/run/)  
In the section clean up, it is mentioned that - **to automatically clean up the container and remove the file system when the container exits, you can add the --rm flag**

But i can’t see any option in Ansible’s docker module to specify this. How can do this in Ansible ?

---

<div class="post-metadata">

**Author:** ![ishan\_jain](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@ishan\_jain](https://forum.ansible.com/u/ishan_jain)\
**Post date:** [April 4, 2016, 7:01am UTC](https://forum.ansible.com/t/how-can-i-specify-rm-with-docker-run-command-to-make-sure-the-containers-are-cleaned-up-on-exit/21030/2 "2016-04-04T07:01:40Z")

</div>

Still couldn’t find anything. There’s gotta be a way in ansible to specify this or maybe an option to specify all other switches.
