title: ansible docker postgres volume
body: <p>i am doing some postgres deployment with docker, ansible and terraform in aws</p>
  
  <p>things are going relatively well, i start the instance with terraform, provision the instance with docker using ansible, start my postgres container with ansible also, and attach a ebs volume to my instance, which i intend to use as the main data storage.</p>
  
  <p>but i am confused as to how to attach the volume to the docker (not to the instance as i am able to do that using terraform)</p>
  
  <p>i imagine it is possible using ansible or modifiying the dockerfile, but the documentation of the "<strong>volume</strong>" which seems to be the answer is not that clear to me.</p>
  
  <p>so if i had an ansible playbook like this:</p>
  
  <pre><code>name: Start postgis
  docker_container:
  name: postgis
  image: "{{ ecr_url }}"    
  network_mode: bridge
  exposed_ports:
    5432
  published_ports:
    5432:5432
  state: started
  </code></pre>
  
  <p>how would i specify the ebs volume to be used for the data storage of Postgres?</p>
  
  <pre><code>resource "aws_volume_attachment" "ebs-volume-postgis-attach" {
  device_name = "/dev/xvdh"
  volume_id = "${aws_ebs_volume.ebs-volume-postgis.id}"
  instance_id = "${aws_instance.postgis.id}"
  }
  </code></pre>
  
  <p>that was the code used to attach the ebs volume, in case someone is interested</p>
  
  <p>please ask any kind of info that you need, all help is deeply apreciated</p>