希望这有帮助!I cannot connect to external mongodb server from my docker swarm cluster.As I understand this is because of cluster uses overlay network driver. Am I right?If not, how does docker overlay driver works and how can I connect to external mongodb server from cluster? 解决方案 Q. How does the docker overlay driver work?I would recommend this good reference for understanding docker swarm network overlay, and more globally, Docker's architecture.This states that:So, in multi-host docker swarm mode, with this example setup :Back to your question:How can I connect to an external mongodb server form cluster?For your external mongodb (let's say you have a DNS for that mongodb.mydomain.com), you are in the same situation as the client in above architecture, wanting to connect to docker.com, except that you certainly don't wan't to expose that mongodb.mydomain.com to the entire web, so you may have declared it in your internal cluster DNS server.Then, how to tell docker engine to use this internal DNS server to resolve mongodb.mydomain.com?You have to indicate in your docker service task that you want to use an internal DNS server, like so:docker service create--name myservice--network my-overlay-network--dns=10.0.0.2myservice:latestThe important thing here is --dns=10.0.0.2. This will tell the Docker engine to use the DNS server at 10.0.0.2:53 as default if it can not resolve the DNS name in the VIP.Finally, when you say :I would say no, as there is a built in method in docker engine to forward unknown DNS name coming from overlay network to the DNS server you want.Hope this helps! 这篇关于什么是覆盖网络以及 DNS 解析如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-07 08:25