Deploy mongodb in docker, and the data files are persisted to mac (my local machine). The test found that as long as the data file directory is placed in docker, there will be no problem. Once the file is placed, it is mounted through the docker -v command The following error pops up in the folder that comes over:
docker startup command:
docker run -it -v /Usr/happyhour7/code/data:/data mongodb /bin/bash
root@aba9b0873a23:/# mongod --dbpath=/data/db
2017-01-05T08:40:32.211 0000 I CONTROL [initandlisten] MongoDB starting : pid=15 port=27017 dbpath=/data /db 64-bit host=aba9b0873a23
2017-01-05T08:40:32.211 0000 I CONTROL [initandlisten] db version v3.4.1
2017-01-05T08:40:32.211 0000 I CONTROL [initandlisten] git version: 5e103c4f5583e2566a45d740225dc250baacfbd7
2017-01-05T08:40:32.211 0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2017-01-05T08:40:32.211 0000 I CONTROL [initandlisten] allocator: tcmalloc
2017-01-05T08:40:32.211 0000 I CONTROL [initandlisten] modules: none
2017-01-05T08:40:32.211 0000 I CONTROL [initandlisten] build environment:
2017-01-05T08:40:32.211 0000 I CONTROL [initandlisten] distmod: ubuntu1404
2017-01-05T08:40:32.211 0000 I CONTROL [initandlisten] distarch: x86_64
2017-01-05T08:40:32.211 0000 I CONTROL [initandlisten] target_arch: x86_64
2017-01-05T08:40:32.211 0000 I CONTROL [initandlisten] options: { storage: { dbPath: "/data/db" } }
2017-01-05T08:40:32.218 0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=489M,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal, compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2017-01-05T08:40:32.229 0000 E STORAGE [initandlisten] WiredTiger error (22) 1483605632:229032, connection: /data/db/: directory-sync: fdatasync: Invalid argument
2017-01-05T08:40:32.230 0000 I - [initandlisten] Fatal Assertion 28561 at src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 264
2017-01-05T08:40:32.230 0000 I - [initandlisten]
*aborting after fassert() failure
My local machine: mac, docker system: ubuntu@14.04
Are you running Docker directly on your MacBook? The official documentation about Volume says this:
File sharing
You can decide which directories on your Mac to share with containers.
Add a Directory - Click + and navigate to the directory you want to add.
Click Apply & Restart to make the directory available to containers using Docker’s bind mount (-v) feature.
It means you need to configure Docker before you can use Volume
Reference:
Get started with Docker for Mac