ranjitha rao
ranjitha rao

Reputation: 57

How to mount mongodb data from docker container to localhost storage on Windows 10?

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)?

Upvotes: 3

Views: 7549

Answers (3)

Raidel Ross
Raidel Ross

Reputation: 15

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!!

Upvotes: 1

bmabir17
bmabir17

Reputation: 141

@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

Upvotes: 1

joonghyup cha
joonghyup cha

Reputation: 624

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

Upvotes: 3

Related Questions