title: Confused about volumes_from and volumes usage in docker-compose.yml
body: <p>I am trying to understand - maybe I already did maybe not - the differences between <code>volumes_from</code> and <code>volumes</code> usage in a <code>docker-compose.yml</code> file. I have read docs already but from there is not so clear to me so I am doing a real exercise. </p>
  
  <p>I have the following setup:</p>
  
  <ul>
  <li>a root directory</li>
  <li>a directory named <code>php-apache</code> with a <code>Dockerfile</code> under root</li>
  <li>a directory named <code>mongo</code> with a <code>Dockerfile</code> under root</li>
  <li>a <code>docker-compose.yml</code> file under root</li>
  </ul>
  
  <blockquote>
    <p>Note: If it's not clear to you, take a look <a href="https://github.com/reypm/php55-dev/tree/mongodb-test" rel="nofollow noreferrer">here</a> and everything exposed down below is right there as well (<code>mongodb-test</code> branch)</p>
  </blockquote>
  
  <ul>
  <li><p>At <code>php-apache/Dockerfile</code> I have the following entry:</p>
  
  <pre><code>VOLUME /data /data
  </code></pre></li>
  <li><p>At <code>mongo/Dockerfile</code> I have the following entry:</p>
  
  <pre><code>VOLUME /data/db /data/configdb
  </code></pre></li>
  <li><p>At <code>docker-compose.yml</code> I have the following:</p>
  
  <pre><code>version: '2'
  services:
      php-apache:
          container_name: "php55-dev"
          image: reynierpm/php55-dev
          ports:
              - "80:80"
          environment:
              PHP_ERROR_REPORTING: 'E_ALL &amp; ~E_DEPRECATED &amp; ~E_NOTICE'
          volumes:
              - ~/mmi:/var/www
          volumes_from:
              - volumes_data
      mongo:
          container_name: "mongodb"
          image: reynierpm/mongodb
          ports:
              - "27017:27017"
          volumes_from:
              - volumes_data
      volumes_data:
          image: tianon/true
          volumes:
              - ~/data/mongo:/data/db
              - ~/data:/data
  </code></pre></li>
  </ul>
  
  <p>This is what I am understanding from that setup:</p>
  
  <ul>
  <li>The image <code>reynierpm/php55-dev</code> will expose a <code>/data</code> directory and this will be mapped to <code>~data:/data</code> in <code>tianon/true</code> image</li>
  <li>The image <code>reynierpm/mongodb</code> will expose a <code>/data/db</code> to the outside and mapped to <code>/data/configdb</code> internally then the <code>/data/db</code> is mapped to <code>~/data/mongo:/data/db</code> in <code>tianon/true</code> image.</li>
  </ul>
  
  <p>Is a mess in my head right now because what do I want to achieve is the following:</p>
  
  <ul>
  <li>Keep mapped the code on the host to the container (this line <code>&lt;path_on_host&gt;:/var/www</code> on <code>docker-compose.yml</code>)</li>
  <li>Keep data stored on a local directory in the host</li>
  </ul>
  
  <p>So, it's fine what I am doing? Feel free to made any modification at this setup since I am still learning.</p>