如何使用Thunder Client将Docker Compose容器连接到MongoDB Compass。

huangapple go评论63阅读模式
英文:

how to connect Docker compose container to mongoDB compass using thunder client

问题

我想在 MongoDB Compass 中获取 Thunder Client 请求的结果,但我的 MongoDB Compass 没有显示这个结果。如何修复它?

这是错误信息。

YAML 文件

英文:

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?

this is the error.

Yaml file

答案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:27017localhost: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

huangapple
  • 本文由 发表于 2023年4月4日 14:44:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/75926230.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定