Deploy mongodb in doc and report the error directory-sync: fdatasync: invalid argument.

  docker, question

Mongodb is deployed in the docker, and the data files are persisted into the mac (my own machine). The test found that as long as the directory of the data files is placed in the docker, there is no problem. Once the files are placed in the folder mounted through the docker -v command, the following error will pop up:

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 computer: mac, docker system: ubuntu@14.04

Are you running Docker directly on MacBook? The official document on Volume said 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.

This means that you need to configure Docker before you can use Volume.

Reference:
Get started with Docker for Mac