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

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

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

Thanks. Now’s clear :slight_smile:

–BK

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