windows - 无法在 Windows 上启动 docker mongo 图像

标签 windows mongodb docker

启动图像时出现以下错误:

 2019-02-27T17:09:41.095+0000 E STORAGE  [initandlisten] WiredTiger error (17) [1551287381:95206][1:0x7fae36fc4a40], connection: __posix_open_file, 715:
/data/db/WiredTiger.wt: handle-open: open: File exists Raw: [1551287381:95206][1:0x7fae36fc4a40], connection: __posix_open_file, 715: /data/db/WiredTiger.wt: handle-open: open: File exists
2019-02-27T17:09:41.108+0000 I STORAGE  [initandlisten] WiredTiger message unexpected file WiredTiger.wt found, renamed to WiredTiger.wt.6
2019-02-27T17:09:41.111+0000 E STORAGE  [initandlisten] WiredTiger error (1) [1551287381:111166][1:0x7fae36fc4a40], connection: __posix_open_file, 715:
/data/db/WiredTiger.wt: handle-open: open: Operation not permitted Raw: [1551287381:111166][1:0x7fae36fc4a40], connection: __posix_open_file, 715: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted
2019-02-27T17:09:41.149+0000 E STORAGE  [initandlisten] WiredTiger error (17) [1551287381:149030][1:0x7fae36fc4a40], connection: __posix_open_file, 715: /data/db/WiredTiger.wt: handle-open: open: File exists Raw: [1551287381:149030][1:0x7fae36fc4a40], connection: __posix_open_file, 715: /data/db/WiredTiger.wt: handle-open: open: File exists
2019-02-27T17:09:41.153+0000 I STORAGE  [initandlisten] WiredTiger message unexpected file WiredTiger.wt found, renamed to WiredTiger.wt.7
2019-02-27T17:09:41.156+0000 E STORAGE  [initandlisten] WiredTiger error (1) [1551287381:156133][1:0x7fae36fc4a40], connection: __posix_open_file, 715:
/data/db/WiredTiger.wt: handle-open: open: Operation not permitted Raw: [1551287381:156133][1:0x7fae36fc4a40], connection: __posix_open_file, 715: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted
2019-02-27T17:09:41.177+0000 E STORAGE  [initandlisten] WiredTiger error (17) [1551287381:177375][1:0x7fae36fc4a40], connection: __posix_open_file, 715: /data/db/WiredTiger.wt: handle-open: open: File exists Raw: [1551287381:177375][1:0x7fae36fc4a40], connection: __posix_open_file, 715: /data/db/WiredTiger.wt: handle-open: open: File exists
2019-02-27T17:09:41.192+0000 I STORAGE  [initandlisten] WiredTiger message unexpected file WiredTiger.wt found, renamed to WiredTiger.wt.8
2019-02-27T17:09:41.194+0000 E STORAGE  [initandlisten] WiredTiger error (1) [1551287381:194762][1:0x7fae36fc4a40], connection: __posix_open_file, 715:
/data/db/WiredTiger.wt: handle-open: open: Operation not permitted Raw: [1551287381:194762][1:0x7fae36fc4a40], connection: __posix_open_file, 715: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted
2019-02-27T17:09:41.200+0000 W STORAGE  [initandlisten] Failed to start up WiredTiger under any compatibility version.
2019-02-27T17:09:41.200+0000 F STORAGE  [initandlisten] Reason: 1: Operation not permitted
2019-02-27T17:09:41.201+0000 F -        [initandlisten] Fatal Assertion 28595 at src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 704

.env文件夹值为

MONGO_SAVE_PATH=./database/db

数据库 docker 文件:

FROM mongo:latest
VOLUME ["/data/db"]
WORKDIR /data
EXPOSE 27017
CMD ["mongod"]

docker-compose.yml 数据库容器

services:
  my-mongo-db:
  build: ./database
  ports:
   - 32815:27017
  volumes:
- ./database/db:/data/db

我不确定如何解决这个问题。但是,在 linux 和 Mac 上不会出现此问题。

最佳答案

WARNING (Windows & OS X): The default Docker setup on Windows and OS X uses a VirtualBox VM to host the Docker daemon. Unfortunately, the mechanism VirtualBox uses to share folders between the host system and the Docker container is not compatible with the memory mapped files used by MongoDB (see vbox bug, docs.mongodb.org and related jira.mongodb.org bug). This means that it is not possible to run a MongoDB container with the data directory mapped to the host.

Answer from docker mongo GitHub

持久化数据的解决方法:

docker volume create --name=mongodata
docker run -d -p 27017:27017 -v mongodata:/data/db --name=mymongo mongodb:3.3

更多信息 here

关于windows - 无法在 Windows 上启动 docker mongo 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54911021/

相关文章:

linux - Unix 和 Windows 路径之间的所有区别是什么?

windows - 有什么软件可以将 64 位 ODBC 应用程序桥接到 Windows 上的 32 位 ODBC 驱动程序?

windows - 事件是否发出信号意味着什么?

python - 如何用pymongo连接远程mongodb

java - 使用 Java 更新 MongoDB 中的特定字段而不是整个文档

javascript - 将变量传递给 mongo 修饰符

postgresql - Postgres 在数据库 : Could not detect default username 上运行查询时出错

node.js - 基于 Electron 的应用程序的许可证生成

docker - 使用 Docker 管理开发/测试/生产环境

docker - 无法在 Docker 容器中使用挂载