首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何将mongodb数据从docker容器挂载到Windows 10上的本地主机存储?

如何将mongodb数据从docker容器挂载到Windows 10上的本地主机存储?
EN

Stack Overflow用户
提问于 2020-01-03 12:36:26
回答 3查看 4.9K关注 0票数 2

当我尝试使用以下命令为mongo创建卷时:

停靠程序运行-p 27015:27017 -v C:\myPath\mongodump:/data/db mongo I得到错误:

代码语言:javascript
运行
复制
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

相关文档指出,这是因为Docker容器与MongoDB使用的内存映射文件不兼容。信息:/mongo

是否有可能在windows中安装mongodb卷?或者其他任何工作都可以自动将mongo转储到本地存储(如何将其写入docker-组合文件)?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2020-01-03 12:54:53

只能通过linux文件系统访问docker。

要解决这个问题,您必须分别创建卷。

就像下面。请看这个链接

代码语言:javascript
运行
复制
docker volume create --name=mongodata
docker run -d -p 27015:27017 -v mongodata:/data/db mongo
票数 3
EN

Stack Overflow用户

发布于 2021-05-29 12:37:54

如果有人也有相同的错误,但是使用了@r_zelazny组合,下面的解决方案解决了我的问题

代码语言:javascript
运行
复制
version: '3.3'
services:
  mongodb:
    image: mongo
    container_name: mongodb
    volumes:
      - mongodata:/data/db
    ports:
      - 27017:27017
volumes:
  mongodata:

参考文献

这也适用于2.3版撰写文件版本

票数 1
EN

Stack Overflow用户

发布于 2022-08-27 16:42:14

这是我在窗户上的工作

  1. 创建文件夹'C:/mongodb/db'
  2. 使用docker stack deploy -c stack.yml test运行下一段代码
代码语言:javascript
运行
复制
services:

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

数据库中的所有数据将存储在'C:/mongodb/db'中,使数据在windows中保持不变。

你好!!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59578766

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档