4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

WSL2でdocker + mongoDBでvolumesでローカルパスを指定するとエラー

Last updated at Posted at 2019-06-17

いまのところ

結論から書くと、以下の方の記事のようにWindowsやWSLだと「なにかおかしい」らしい。

2019/6/22追記:
docker volume create コマンドでデータボリュームを作成し、それをvolumesでマウントすると動作する。
ただしホスト側の自分の好きなパスにデータは格納できない。

言い訳

※dockerもmongoDBもWSLもほとんど触ったこと無い人間なので、思いきり間違っているところはあるかもしれません。

現象

docker-compose.yaml
version: '3'

services:
  mongodb:
    image: mongo
    restart: always
    container_name: mongo
    ports:
      - "27017:27017"
    volumes:
      - ./misc/data:/data/db

と相対パスで書いて docker-compose up してもエラーがでて起動しない。
(./misc/data は空の状態)

mongo      | 2019-06-17T01:50:18.109+0000 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
mongo      | 2019-06-17T01:50:18.111+0000 I CONTROL  [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=110690427a7a
mongo      | 2019-06-17T01:50:18.111+0000 I CONTROL  [initandlisten] db version v4.0.10
mongo      | 2019-06-17T01:50:18.111+0000 I CONTROL  [initandlisten] git version: c389e7f69f637f7a1ac3cc9fae843b635f20b766
mongo      | 2019-06-17T01:50:18.111+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
mongo      | 2019-06-17T01:50:18.111+0000 I CONTROL  [initandlisten] allocator: tcmalloc
mongo      | 2019-06-17T01:50:18.111+0000 I CONTROL  [initandlisten] modules: none
mongo      | 2019-06-17T01:50:18.111+0000 I CONTROL  [initandlisten] build environment:
mongo      | 2019-06-17T01:50:18.111+0000 I CONTROL  [initandlisten]     distmod: ubuntu1604
mongo      | 2019-06-17T01:50:18.111+0000 I CONTROL  [initandlisten]     distarch: x86_64
mongo      | 2019-06-17T01:50:18.111+0000 I CONTROL  [initandlisten]     target_arch: x86_64
mongo      | 2019-06-17T01:50:18.111+0000 I CONTROL  [initandlisten] options: { net: { bindIpAll: true } }
mongo      | 2019-06-17T01:50:18.124+0000 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=10965M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
mongo      | 2019-06-17T01:50:19.026+0000 E STORAGE  [initandlisten] WiredTiger error (1) [1560736219:26117][1:0x7f8208338a80], connection: __posix_open_file, 715: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted Raw: [1560736219:26117][1:0x7f8208338a80], connection: __posix_open_file, 715: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted
mongo      | 2019-06-17T01:50:19.057+0000 E STORAGE  [initandlisten] WiredTiger error (17) [1560736219:57235][1:0x7f8208338a80], connection: __posix_open_file, 715: /data/db/WiredTiger.wt: handle-open: open: File exists Raw: [1560736219:57235][1:0x7f8208338a80], connection: __posix_open_file, 715: /data/db/WiredTiger.wt: handle-open: open: File exists
mongo      | 2019-06-17T01:50:19.063+0000 I STORAGE  [initandlisten] WiredTiger message unexpected file WiredTiger.wt found, renamed to WiredTiger.wt.1
mongo      | 2019-06-17T01:50:19.068+0000 E STORAGE  [initandlisten] WiredTiger error (1) [1560736219:67999][1:0x7f8208338a80], connection: __posix_open_file, 715: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted Raw: [1560736219:67999][1:0x7f8208338a80], connection: __posix_open_file, 715: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted
mongo      | 2019-06-17T01:50:19.105+0000 E STORAGE  [initandlisten] WiredTiger error (17) [1560736219:105959][1:0x7f8208338a80], connection: __posix_open_file, 715: /data/db/WiredTiger.wt: handle-open: open: File exists Raw: [1560736219:105959][1:0x7f8208338a80], connection: __posix_open_file, 715: /data/db/WiredTiger.wt: handle-open: open: File exists mongo      | 2019-06-17T01:50:19.108+0000 I STORAGE  [initandlisten] WiredTiger message unexpected file WiredTiger.wt found, renamed to WiredTiger.wt.2
mongo      | 2019-06-17T01:50:19.110+0000 E STORAGE  [initandlisten] WiredTiger error (1) [1560736219:110197][1:0x7f8208338a80], connection: __posix_open_file, 715: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted Raw: [1560736219:110197][1:0x7f8208338a80], connection: __posix_open_file, 715: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted
mongo      | 2019-06-17T01:50:19.111+0000 W STORAGE  [initandlisten] Failed to start up WiredTiger under any compatibility version.
mongo      | 2019-06-17T01:50:19.111+0000 F STORAGE  [initandlisten] Reason: 1: Operation not permitted
mongo      | 2019-06-17T01:50:19.111+0000 F -        [initandlisten] Fatal Assertion 28595 at src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 704
mongo      | 2019-06-17T01:50:19.111+0000 F -        [initandlisten]
mongo      |
mongo      | ***aborting after fassert() failure
mongo      |

これが

sudo docker run -p 27017:27017 --name dev-mongo -d mongo

のようにvolumes無しで直接mongoイメージから起動するとエラーもなく動作する。

最初はWSL2のせいかと思っていたが、どうも何かWindowsとdocker + mongoDBの相性が悪いのだろう。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?