3

When I try to create volume for mongo using below command:

docker run -p 27015:27017 -v C:\myPath\mongodump:/data/db mongo I get the error:

2020-01-03T10:08:58.002+0000 I  CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-01-03T10:08:58.006+0000 I  CONTROL  [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=bab5c142014f
2020-01-03T10:08:58.006+0000 I  CONTROL  [initandlisten] db version v4.2.2
2020-01-03T10:08:58.006+0000 I  CONTROL  [initandlisten] git version: a0bbbff6ada159e19298d37946ac8dc4b497eadf
2020-01-03T10:08:58.006+0000 I  CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.1.1  11 Sep 2018
2020-01-03T10:08:58.006+0000 I  CONTROL  [initandlisten] allocator: tcmalloc
2020-01-03T10:08:58.006+0000 I  CONTROL  [initandlisten] modules: none
2020-01-03T10:08:58.006+0000 I  CONTROL  [initandlisten] build environment:
2020-01-03T10:08:58.006+0000 I  CONTROL  [initandlisten]     distmod: ubuntu1804
2020-01-03T10:08:58.006+0000 I  CONTROL  [initandlisten]     distarch: x86_64
2020-01-03T10:08:58.006+0000 I  CONTROL  [initandlisten]     target_arch: x86_64
2020-01-03T10:08:58.006+0000 I  CONTROL  [initandlisten] options: { net: { bindIp: "*" } }
2020-01-03T10:08:58.018+0000 I  STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=478M,cache_overflow=(file_max=0M),session_max=33000,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,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress],
2020-01-03T10:08:58.613+0000 E  STORAGE  [initandlisten] WiredTiger error (1) [1578046138:613590][1:0x7f596d6b6b00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted Raw: [1578046138:613590][1:0x7f596d6b6b00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted
2020-01-03T10:08:58.628+0000 E  STORAGE  [initandlisten] WiredTiger error (17) [1578046138:628759][1:0x7f596d6b6b00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: File exists Raw: [1578046138:628759][1:0x7f596d6b6b00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: File exists
2020-01-03T10:08:58.632+0000 I  STORAGE  [initandlisten] WiredTiger message unexpected file WiredTiger.wt found, renamed to WiredTiger.wt.1
2020-01-03T10:08:58.637+0000 E  STORAGE  [initandlisten] WiredTiger error (1) [1578046138:637909][1:0x7f596d6b6b00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted Raw: [1578046138:637909][1:0x7f596d6b6b00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted
2020-01-03T10:08:58.650+0000 E  STORAGE  [initandlisten] WiredTiger error (17) [1578046138:650974][1:0x7f596d6b6b00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: File exists Raw: [1578046138:650974][1:0x7f596d6b6b00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: File exists
2020-01-03T10:08:58.655+0000 I  STORAGE  [initandlisten] WiredTiger message unexpected file WiredTiger.wt found, renamed to WiredTiger.wt.2
2020-01-03T10:08:58.660+0000 E  STORAGE  [initandlisten] WiredTiger error (1) [1578046138:660725][1:0x7f596d6b6b00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted Raw: [1578046138:660725][1:0x7f596d6b6b00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted
2020-01-03T10:08:58.663+0000 W  STORAGE  [initandlisten] Failed to start up WiredTiger under any compatibility version.
2020-01-03T10:08:58.663+0000 F  STORAGE  [initandlisten] Reason: 1: Operation not permitted
2020-01-03T10:08:58.663+0000 F  -        [initandlisten] Fatal Assertion 28595 at src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 789
2020-01-03T10:08:58.663+0000 F  -        [initandlisten]

***aborting after fassert() failure

Related document says that it is because the Docker container is not compatible with the memory mapped files used by MongoDB. info: https://hub.docker.com/_/mongo .

Is there anyway to make mongodb volume mounting possible in windows?Or any other work around to just take mongo dump to local storage automatically (How to write it in docker-compose file)?

ranjitha rao
  • 57
  • 3
  • 6

3 Answers3

3

docker can only be accessed through the linux file system.

To solve this problem, you have to create volume separately.

like below. and please see this link

docker volume create --name=mongodata
docker run -d -p 27015:27017 -v mongodata:/data/db mongo
joonghyup cha
  • 624
  • 3
  • 12
  • Thanks Roy Cha. I tried the same solution but when I inspect the volume with docker volume inspect mongodata, I get the below info:[ { "CreatedAt": "2020-01-06T04:31:12Z", "Driver": "local", "Labels": {}, "Mountpoint": "/var/lib/docker/volumes/mongodata/_data", "Name": "mongodata", "Options": {}, "Scope": "local" } ] But I am unable to find the path /var/lib/docker/volumes/mongodata/_data – ranjitha rao Jan 06 '20 at 04:41
  • 2
    how would I do this inside a docker-compose file? I specify a mongo service then tried adding `- ./data/db:/data/db` to the `volumes` for this service but mongo crashed with a `*** aborting after fassert() failure` – r_zelazny Mar 11 '20 at 17:12
  • For me the following used to work a year ago using docker-compose, `volumes: - "./mongo_data:/data/db" ` But now i am getting same Error as OP – bmabir17 May 29 '21 at 11:45
1

@r_zelazny If anyone is also having the same error but with docker compose, the following solution fixed my problem

version: '3.3'
services:
  mongodb:
    image: mongo
    container_name: mongodb
    volumes:
      - mongodata:/data/db
    ports:
      - 27017:27017
volumes:
  mongodata:

Reference

This also works with version 2.3 compose file version

bmabir17
  • 131
  • 1
  • 9
0

This work for me on windows

  1. Create the folder 'C:/mongodb/db'

  2. Run the next code with docker stack deploy -c stack.yml test


services:

  mongodb:
    image: mongo
    ports:
      - 27018:27017
    environment:
      MONGO_INITDB_ROOT_USERNAME: user
      MONGO_INITDB_ROOT_PASSWORD: pass
    volumes:
      - C:/mongodb/db:/data/db 

All data from the database will be stored in 'C:/mongodb/db' making the data persistent for windows

Regards!!