title: Docker: How to volume map data from host to container (mongo) in using docker-compose
body: <p>I am trying to volume map, data from host to container using docker-compose. I found this <strong>docker-compose.yml</strong> from <a href="https://www.prisma.io/docs/prisma-server/local-prisma-setup-je3i/" rel="nofollow noreferrer">prisma docs</a></p>
  
  <pre><code>version: '3'
  services:
    prisma:
      image: prismagraphql/prisma:1.34
      restart: always
      ports:
        - '4466:4466'
      environment:
        PRISMA_CONFIG: |
          port: 4466
          managementApiSecret: mysecret42
          databases:
            default:
              connector: mongo
              uri: mongodb://prisma:prisma@mongo
    mongo:
      image: mongo
      restart: always
      environment:
        MONGO_INITDB_ROOT_USERNAME: prisma
        MONGO_INITDB_ROOT_PASSWORD: prisma
      ports:
        - '27017:27017'
      volumes:
        - mongo:/var/lib/mongo
  volumes: 
    mongo:
  </code></pre>
  
  <p>Problem Description:</p>
  
  <ol>
  <li><code>docker-compose up -d</code>, </li>
  <li>add some data to mongodb</li>
  <li><code>docker-compose down</code>. the data gets removed. </li>
  <li>Now, if I again <code>docker-compose up -d</code>. I have to add data again to mongodb </li>
  </ol>
  
  <p><strong>How can I make data persistent (irrespective of container getting destroy)?</strong></p>