我正在尝试使用docker和以下命令运行mongo db,
sudo docker run -v /var/lib/mongo:/data/db -v /home/naggappan/mongo.conf:/etc/mongo.conf -p 27017:27017 mongo -f /etc/mongo.conf
我在系统日志消息中收到以下错误,
May 2 10:19:42 d-mongo-db-dev.india.ks.net kernel: overlayfs: upper fs needs to support d_type. This is an invalid configuration.
May 2 10:19:43 d-mongo-db-dev.india.ks.net kernel: overlayfs: upper fs needs to support d_type. This is an invalid configuration.
May 2 10:19:43 d-mongo-db-dev.india.ks.net kernel: overlayfs: upper fs needs to support d_type. This is an invalid configuration.
May 2 10:19:43 d-mongo-db-dev.india.ks.net kernel: docker0: port 1(vethef7446b) entered blocking state
May 2 10:19:43 d-mongo-db-dev.india.ks.net kernel: docker0: port 1(vethef7446b) entered disabled state
May 2 10:19:43 d-mongo-db-dev.india.ks.net kernel: device vethef7446b entered promiscuous mode
May 2 10:19:43 d-mongo-db-dev.india.ks.net kernel: IPv6: ADDRCONF(NETDEV_UP): vethef7446b: link is not ready
May 2 10:19:43 d-mongo-db-dev.india.ks.net kernel: docker0: port 1(vethef7446b) entered blocking state
May 2 10:19:43 d-mongo-db-dev.india.ks.net kernel: docker0: port 1(vethef7446b) entered forwarding state
May 2 10:19:43 d-mongo-db-dev.india.ks.net kernel: docker0: port 1(vethef7446b) entered disabled state
May 2 10:19:43 d-mongo-db-dev.india.ks.net systemd: Started libcontainer container 7adf209c744c2753d46d6bcbe5623d6f0a56ac9bb71cc61922a056563daf4552.
May 2 10:19:43 d-mongo-db-dev.india.ks.net systemd: Starting libcontainer container 7adf209c744c2753d46d6bcbe5623d6f0a56ac9bb71cc61922a056563daf4552.
May 2 10:19:43 d-mongo-db-dev.india.ks.net kernel: SELinux: mount invalid. Same superblock, different security settings for (dev mqueue, type mqueue)
May 2 10:19:43 d-mongo-db-dev.india.ks.net kernel: IPv6: ADDRCONF(NETDEV_CHANGE): vethef7446b: link becomes ready
May 2 10:19:43 d-mongo-db-dev.india.ks.net kernel: docker0: port 1(vethef7446b) entered blocking state
May 2 10:19:43 d-mongo-db-dev.india.ks.net kernel: docker0: port 1(vethef7446b) entered forwarding state
May 2 10:19:43 d-mongo-db-dev.india.ks.net dockerd-current: time="2018-05-02T10:19:43.615971849Z" level=error msg="containerd: deleting container" error="exit status 1: \"container 7adf209c744c2753d46d6bcbe5623d6f0a56ac9bb71cc61922a056563daf4552 does not exist\\none or more of the container deletions failed\\n\""
May 2 10:19:43 d-mongo-db-dev.india.ks.net kernel: docker0: port 1(vethef7446b) entered disabled state
May 2 10:19:43 d-mongo-db-dev.india.ks.net kernel: docker0: port 1(vethef7446b) entered disabled state
May 2 10:19:43 d-mongo-db-dev.india.ks.net kernel: device vethef7446b left promiscuous mode
May 2 10:19:43 d-mongo-db-dev.india.ks.net kernel: docker0: port 1(vethef7446b) entered disabled state
May 2 10:19:43 d-mongo-db-dev.india.ks.net dockerd-current: time="2018-05-02T10:19:43.822616722Z" level=warning msg="7adf209c744c2753d46d6bcbe5623d6f0a56ac9bb71cc61922a056563daf4552 cleanup: failed to unmount secrets: invalid argument"
但是,如果我只是尝试使用以下命令重定向端口,那么它可以正常工作,
sudo docker run -d -p 27017:27017 mongo
上述命令的问题是,使用像Robo3T这样的UI工具无法从不同的机器访问mongo db服务。连接很开心,但它失败并出现以下错误,因为它绑定到127.0.0.1。要改变这一点,我需要输入如上所述的配置文件并获得错误
May 2 10:12:13 d-mongo-db-dev.india.ks.net journal: 2018-05-02T10:12:13.025+0000 I NETWORK [listener] connection accepted from 15.143.35.10:12729 #3 (2 connections now open)
May 2 10:12:13 d-mongo-db-dev.india.ks.net journal: 2018-05-02T10:12:13.036+0000 I NETWORK [conn3] end connection 15.143.35.10:12729 (1 connection now open)
答案 0 :(得分:0)
关于文件系统问题:Mongodb对其操作系统的文件系统有特殊要求,如MongoDB Production Notes中所述。您需要检查主机系统的文件系统,并在必要时进行更改以确保它与MongoDB兼容。
关于使服务可以从其他机器访问;您需要查看bindIp配置设置,以确保将其正确配置为可在外部接口以及127.0.0.1上访问。
答案 1 :(得分:0)
我在这个yml上使用docker-compose解决了这个问题(从wesleybliss's gist修改):
version: '2'
services:
mongodb:
image: mongo:latest
container_name: "mongodb"
environment:
- MONGO_DATA_DIR=/data/db
- MONGO_LOG_DIR=/dev/null
volumes:
- ./data/db:/data/db
ports:
- 27017:27017
command: mongod --smallfiles --logpath=/dev/null # --quiet
使用' docker-compose up -d'运行此配置后(sudo,如果有必要)我有mongodb绑定在0.0.0.0。它可以从外部IP访问。