在docker中部署mongodb,資料檔案持久化到mac(我本機)中,測試發現,只要將資料檔案目錄放到docker就沒問題,一旦將檔案放到透過docker -v指令掛載過來的資料夾中就回爆出如下錯誤:
docker啟動指令:
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 bit host=aba9b0873a23
2017-01-05T08:40:32.211+0000 I CONTROL [initandlisten] db version v3.4.1
2017-01-05T08:40:30210:300 月 300:05T08:40:30023050235 月]305 月] 103c4f5583e2566a45d740225dc250baacfbd7
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+00000735600056340:32。 1-05T08 :40:32.211+0000 I CONTROL [initandlisten] modules: none
2017-01-05T08:40:32.211+0000 I CONTROL [initandlisten] build environment:0000 I CONTROL [initandlisten] build environment. CONTROL [initandlisten ] distmod: ubuntu1404
2017-01-05T08:40:32.211+0000 I CONTROL [initandlisten] distarch: x86_64
2017-01-05T08:40:300641+602017-01-05T08:40:3002121320021213092121303:00212139303:003:003:003:0021 21323233:005333:0053:00353:003]
2017-01-05T08 :40:32.211+0000 I CONTROL [initandlisten] options: { storage: { dbPath: "/data/db" } }
2017-01-05T08:40:32.218+0000 I STORAGE, netaches] wiitandache_list_list =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=snappy),file_manager=(close_idle_time=snappy),file_manager=(close_idle_time=snappy),file_manager=(close_idle_time=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] WiredT:32.229+0000 E STORAGE [initandlisten] WiredT:32.229+0000 E STORAGE [initandlisten] WiredT. 143262320 : /data/db/: directory-sync: fdatasync: Invalid argument
2017-01-05T08:40:32.230+0000 I - [initandlisten] Fatal Assertion 28561 at src/mongoti/0000240000 月 285619900/702000/7020020/702020202020205402020/70202020205402020540020/702070702020202054020202020540202040204020 20202000 月/
2017-01-05T08:40:32.230+0000 I - [initandlisten]
aborting after fassert() failure 我本機:mac,docker系統:ubuntu@14.04
怪我咯2017-05-02 09:26:13
你是直接在MacBook上執行Docker吧?關於Volume官方文檔是這樣說的:
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.
意思是你需要先配置Docker,然後才能使用Volume
參考:
Get started with Docker for Mac