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

575 views
Skip to first unread message

Bk Lau

unread,
Sep 25, 2014, 3:01:15 PM9/25/14
to ansible...@googlegroups.com
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

Guillaume DEDRIE

unread,
Sep 26, 2014, 6:27:20 PM9/26/14
to ansible...@googlegroups.com
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

Bk Lau

unread,
Sep 27, 2014, 9:15:36 AM9/27/14
to ansible...@googlegroups.com
Thanks. Now's clear :)
--BK

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/Qr51H-vy2iE/unsubscribe.
To unsubscribe from this group and all its topics, 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/39047be4-fb3d-484c-976e-b9bf9d954139%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

tony...@innovatube.com

unread,
Aug 17, 2017, 7:08:04 AM8/17/17
to Ansible Project
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
Reply all
Reply to author
Forward
0 new messages