Boot2Docker (on Windows) running Mongo with shared folder (This file system is not supported)

后端 未结 3 1647
无人共我
无人共我 2021-01-15 15:27

I am trying to start a Mongo container using shared folders on Windows using Boot2Docker. When starting using run -it -v /c/Users/310145787/Desktop/mongo:/data/db mong

3条回答
  •  花落未央
    2021-01-15 15:57

    As an workaround I just copy from a folder before mongo deamon starts. Also, in my case I don't care of journal files, so i only copy database files.

    I've used this command on my docker-compose.yml command: bash -c "(rm /data/db/*.lock && cd /prev && cp *.* /data/db) && mongod" And everytime before stoping the container I use: docker exec bash -c 'cd /data/db && cp $(ls *.* | grep -v *.lock) /prev'

    Note: /prev is set as a volume. path/to/your/prev:/prev

    Another workaround is to use mongodump and mongorestore.

    • in docker-compose.yml: command: bash -c "(sleep 30; mongorestore --quiet) & mongod"
    • in terminal: docker exec mongodump

    Note: I use sleep because I want to make sure that mongo started, and it takes a while.

    I know this involves manual work etc, but I am happy that at least I got mongo with existing data running on my Windows 10 machine, and still can work on my Macbook when I want.

提交回复
热议问题