我正在尝试使用 mongo 从外部连接到 docker 容器中的 mongodb,但出现以下错误。
MongoDB shell version v3.6.5
connecting to: mongodb://127.0.0.1:27017
2018-05-30T14:54:13.950+0200 E QUERY [thread1] Error: network error while attempting to run command 'isMaster' on host '127.0.0.1:27017' :
connect@src/mongo/shell/mongo.js:251:13
@(connect):1:6
exception: connect failed
Run Code Online (Sandbox Code Playgroud)
当我猛击容器时一切都很好。它可能在半年前工作,但现在不会了。我认为这是 docker-compose 的问题,但我不明白。
shell 和服务器的版本是一样的。为了测试这是我的 docker-compose.yaml
version: '3'
networks:
backend:
external:
name: my-mongo-cluster
services:
## Config Servers
config01:
image: mongo
command: mongod --port 27017 --configsvr --replSet configserver --noprealloc --smallfiles --oplogSize 16
volumes:
- ./scripts:/scripts
networks:
- backend
config02:
image: mongo
command: mongod --port 27017 --configsvr …Run Code Online (Sandbox Code Playgroud)