title: Mounting a host directory to a docker container from yaml/compose file
body: <p>I have part of my current config like this</p>
  
  <pre><code>mymicroservice:
    image: service_img
    networks: myoverlay
    volumes:
      - /Users/abcdUser/mountme:/opt/company/
  </code></pre>
  
  <p>This does the job as my machine's directory gets mounted to <code>/opt/company</code> when I deploy the docker swarm service stack.</p>
  
  <p>However, I want to specify the source directory under a separate <code>volumes:</code> and then specify that name over there. I think this is possible but I am not able to find the syntax. </p>
  
  <p>So I want something along the following lines but not able to do so:</p>
  
  <pre><code>mymicroservice:
    image: service_img
    networks: myoverlay
    volumes:
      - myownvolume:/opt/company/
  
  
  volumes:
   - myownvolume: /Users/abcdUser/mountme
  </code></pre>
  
  <p>I want to clarify that <code>myownvolume</code> here is just pointing to the directory <code>/Users/abcdUser/mountme</code> and I am not intending to create a docker volume. Or there is any other better way to do this?</p>