title: Mounting a host directory through docker-compose file version "3" and re-using the data-volume
body: <p>I have Docker commands to create a container and then use that container's name with <strong><em>--volumes-from</em></strong> to run another container and it works fine -</p>
  
  <pre><code>docker create -v /home/dev/docker/my/config:/home/myuser/4.0/config --name shared-config my/configurator:4.0.0
  </code></pre>
  
  <p>The above would create a new container by name <strong>shared-config</strong> from image <strong>my/configurator:4.0.0</strong></p>
  
  <p>and when trying to run any other container (say my/oms:4.0.0) I can simply use volume from container named shared-config using <strong><em>--volumes-from</em></strong> </p>
  
  <pre><code>docker run --volumes-from shared-config -p 8083:8080 -d my/oms:4.0.0
  </code></pre>
  
  <p>using <strong><em>--volumes-from</em></strong> we can use the volume multiple times in which ever container it is required.</p>
  
  <p>Till here everything seems fine.</p>
  
  <p>Now, I am trying to do the above in docker-compose using file-format version "3" and not able to understand <strong>how will I be able to re-use data-volume once it is created</strong>. Since as per docker-compose in version 3  they have <a href="https://docs.docker.com/compose/compose-file/#version-3" rel="nofollow noreferrer" title="https://docs.docker.com/compose/compose-file/#version-3">discontinued use of <strong><em>--volumes-from</em></strong></a>.
  They say - </p>
  
  <blockquote>
    <p>To share a volume between services, define it using the top-level volumes option and reference it from each service that shares it using the service-level volumes option.</p>
  </blockquote>
  
  <p>In above statement they are referring to named volumes, please refer from <a href="https://docs.docker.com/compose/compose-file/#/volume-configuration-reference" rel="nofollow noreferrer">here</a>.</p>
  
  <p>But I just want to mount a host directory as a data volume and re-use that data volume. My question is how do I reuse this data-volume through docker-compose file version "3".
  To the simplest, for each service I want to run through docker-compose I can use volume key at service level</p>
  
  <pre><code>version: "3"
  services:
    my-oms:
      image: my/oms:4.0.0
      ports:
        - "8083:8080"
      volumes:
        - /home/dev/docker/my/config:/home/myuser/4.0/config
  </code></pre>
  
  <p>But what if I want to use my host's directory (/home/dev/docker/my/config) as a data volume in different services. Should I have the volume key for each service or actually there is a better way in docker-compose version "3" where I can re-use the data-volume in other services (how we did using --volumes-from).</p>
  
  <p>Any pointers or suggestions or something that I missed?</p>