英文:
how to connect Docker compose container to mongoDB compass using thunder client
问题
我想在 MongoDB Compass 中获取 Thunder Client 请求的结果,但我的 MongoDB Compass 没有显示这个结果。如何修复它?
英文:
enter image description here
i want to get this thunder client request result in MongoDB compass. but my MongoDb compass not shown thiss result? how to fix it?
答案1
得分: 0
只使用主机名 mongo_db
连接来自Docker桥网络的另一个容器时,Docker Compose为您创建的桥网络上使用未映射的端口号:27017。
当您从主机机器连接时,您需要使用 localhost
和映射的端口号。
因此,您需要在Compass中将URI更改为 mongodb://localhost:2717/express_mongoosen
。
将端口映射到2717并没有什么问题,所以如果这是有意的,请继续使用它。但看起来可能是一个打字错误,您可能本意是要使用27017?
英文:
You only use the hostname mongo_db
when you connect to the container from another container on the Docker bridge network that docker-compose creates for you. On the bridge network you use the unmapped port number: 27017.
When you connect from the host machine, you need to use localhost
and the mapped port number.
So you need to change your URI in Compass to mongodb://localhost:2717/express_mongoosen
.
There's nothing wrong with mapping to port 2717 as such, so if that's intentional, then keep using it. But it does look like it might be a typo and you meant to use 27017?
答案2
得分: -1
Replace mongo_db:27017
with 127.0.0.1:27017
或localhost:27017
and your docker compose have incorrect port binding for mongodb.
英文:
replace mongo_db:27017 by 127.0.0.1:27017 or localhost:27017 and your docker compose have incorrect port binding for mongodb
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论