启动图像时出现以下错误:
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上,不会出现此问题。
答案 0 :(得分:8)
如果您使用的是docker-compose,则以下是复制以上答案的方法。
services:
mongodb_container:
...
volumes:
- mongodata:/data/db
volumes:
mongodata:
请不要让上面的示例仅指出mongodb存储所需的yml文件的一部分。
答案 1 :(得分:3)
尽管Augustas是正确的,但是我发现this的答案对于docker-compose.yml
尤其有用。
作为解决方法,您可以做的是:
.env
文件相同的路径中创建一个docker-compose
文件,并将当前路径存储在这样的环境变量中:MONGO_HOST_DATA=/Users/user123/MyMongoProject //path to mongo data folder (for C:\Users\user123\MyMongoProject)
docker-compose
文件中,替换上述变量: services:
my-mongo-db:
build: ./database
ports:
- 32815:27017
volumes:
- ${MONGO_HOST_DATA}/database/db:/data/db
docker-compose config
此外,如果您使用C:\以外的任何磁盘驱动器,则可能要更改Docker文件共享设置:
希望这会有所帮助。
答案 2 :(得分:2)
警告(Windows和OS X):Windows和OS X上的默认Docker设置 使用VirtualBox VM托管Docker守护程序。不幸的是, VirtualBox用于在主机系统和 Docker容器与内存映射文件不兼容 由MongoDB使用(请参阅vbox错误,docs.mongodb.org和相关内容 jira.mongodb.org错误)。这意味着无法运行 将数据目录映射到主机的MongoDB容器。
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
答案 3 :(得分:0)
并非完全相同,但是在Ubuntu中为mongo简单地为Docker旋转一个Docker容器并尝试将现有目录挂载到该容器时,我看到了相同的错误消息:
docker run --name some-mongo -p 27017:27017 -v $PWD/db-data:/data/db -d mongo
在我的情况下,仅当我尝试从安装的HDD上的目录运行命令时才会显示错误,并且能够通过将代码库和/ db-data目录迁移到我的SSD(Ubuntu)来解决此问题已安装。