title: Data does not persist to host volume with docker-compose.yml for MongoDB
body: <p>Have docker installed on my Mac along with MongoDB image.  When I start the container with volume specified directly in the docker run command, the data gets persisted even after I stop the container.  But the same does not work when I do it via <code>docker-compose.yml</code>.  Can someone suggest what's wrong with the <code>docker-compose.yml</code> file?</p>
  
  <p>When I do this, the data gets persisted:</p>
  
  <p><code>docker run --name mongodb -v /Users/shrap7/projects/mongodb/data:/data/db --rm -d mongo</code></p>
  
  <p>But when I try the same with <code>docker-compose.yml</code> - it does not persist data.  </p>
  
  <pre><code>version: '3.4'
  services:
      mongodb:
         image: mongo:latest
         container_name: "mongodb"
         volumes:
            - /Users/shrap7/projects/mongodb/data:/data/db
         ports:
            - 27017:27017
  </code></pre>
  
  <p>I tried with double quotes, tried relative path, i.e. <code>./data:/data/db</code>, but no luck.  Thank you.</p>