简体   繁体   中英

Mounting host volume for mongo data in docker compose container

I'd like to run mongo in a docker container, alongside some others I'm using via docker-compose.

I thought mounting the volume like so would allow for it to persist data outside the container:

db:
  image: mongo
  command: -smallfiles -nojournal
  volumes:
    - ./mongo_data:/data

It seems to create some directories, but there's no files on the host mount. The data files are present on the container.

$ find mongo_data
mongo_data
mongo_data/configdb
mongo_data/db

This seems to work:

db:
  image: mongo:3
#  command: -smallfiles -nojournal
  volumes:
    - ./mongo_data:/data/db

I suspect it's just the change to the volumes value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM