# docker module  - what is the syntax for 'volumes' parameter

**URL:** <https://forum.ansible.com/t/docker-module-what-is-the-syntax-for-volumes-parameter/16343>\
**Category:** Ansible Project\
**Created:** [September 25, 2014, 7:01pm UTC](https://forum.ansible.com/t/docker-module-what-is-the-syntax-for-volumes-parameter/16343 "2014-09-25T19:01:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bk\_Lau](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@Bk\_Lau](https://forum.ansible.com/u/Bk_Lau)\
**Post date:** [September 25, 2014, 7:01pm UTC](https://forum.ansible.com/t/docker-module-what-is-the-syntax-for-volumes-parameter/16343/1 "2014-09-25T19:01:15Z")

</div>

Hi :

What is the syntax for the “volumes” parameter in the docker module?.  
There is no example.  
Assume that I have a host dirs at “/opt/my\_logs1” and “/opt/my\_logs2” and I want to map it to a container volumes at “/opt/logs1” and  
“/opt/logs2” respectively.  
So what would the syntax be?  
Pls advise.

Thanks,

/BK

---

<div class="post-metadata">

**Author:** ![Guillaume\_DEDRIE](https://avatars.discourse-cdn.com/v4/letter/g/4da419/32.png) [@Guillaume\_DEDRIE](https://forum.ansible.com/u/Guillaume_DEDRIE)\
**Post date:** [September 26, 2014, 10:27pm UTC](https://forum.ansible.com/t/docker-module-what-is-the-syntax-for-volumes-parameter/16343/2 "2014-09-26T22:27:20Z")

</div>

Hi /BK,  
If you want to manage volumes in Docker containers, you can use the same Docker CLI-style syntax: [host\_directory]:[container\_directory] into the volumes parameters (for multiple mounts, use list syntax).

I have an example with the official PostgreSQL Docker image:

- name: Run PostgreSQL Docker image  
docker:  
name: postgresql  
image: postgres  
ports: 5432:5432  
volumes:
- /opt/postgresql/data:/var/lib/postgresql/data  
state: running

For your example, volumes should end up with something like that:

[…]  
volumes:

- /opt/my\_logs1:/opt/my\_logs1
- /opt/my\_logs2:/opt/my\_logs2  
[…]

I hope that my answer will be helpfull.

Regards,  
Guillaume

---

<div class="post-metadata">

**Author:** ![Bk\_Lau](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@Bk\_Lau](https://forum.ansible.com/u/Bk_Lau)\
**Post date:** [September 27, 2014, 1:15pm UTC](https://forum.ansible.com/t/docker-module-what-is-the-syntax-for-volumes-parameter/16343/3 "2014-09-27T13:15:33Z")

</div>

Thanks. Now’s clear 🙂

–BK

---

<div class="post-metadata">

**Author:** ![tony.dang](https://avatars.discourse-cdn.com/v4/letter/t/f04885/32.png) [@tony.dang](https://forum.ansible.com/u/tony.dang)\
**Post date:** [August 17, 2017, 11:08am UTC](https://forum.ansible.com/t/docker-module-what-is-the-syntax-for-volumes-parameter/16343/4 "2017-08-17T11:08:04Z")

</div>

Hi Guillaume,

I mount the volumes as spec but it cannot mount successfully as expected as using `docker run -v`  
Do you have any idea? Thank you!

Tony
