title: Mongo db persistence in docker with volumes
body: <p>I'm trying to create a mongo database container, but can't make the data to persist. 
  Here is my docker-compose.yml</p>
  
  <pre><code>version: "3.2"
  services:
    mongodb:
    image: mongo:2.4
    command: --smallfiles 
    ports:
      - 27017:27017
    volumes:
      - type: volume
        source: mongodb_data_volume
        target: /data
  volumes:
    mongodb_data_volume:
      external: true
  </code></pre>
  
  <p>After docker-compose, and exec -it into the mongodb, I create a new empty database and then I list the contents of the mounted volume:</p>
  
  <pre><code>root@cf8330019f91:/data/db# ls
  _tmp     admin.1   journal  local.ns
  admin.0  admin.ns  local.0  mongod.lock
  </code></pre>
  
  <p>But then I do a compose down and up cycle and the same mounted volume is reset to the initial values.</p>
  
  <pre><code>root@d18bda47d0b3:/data/db# ls
  _tmp  journal  local.0  local.ns  mongod.lock
  </code></pre>
  
  <p>I've tried to only stop the container instead compose down, and then the data persisted... which would indicate that I'm still using the internal storage. If this is the case, how do I make it to use the external volume?</p>
  
  <p>I'm using a mac and docker version 18.06.1-ce-mac73.</p>