docker - Docker网络功能如何提供服务发现?

标签 docker

正如 docker 文档所说:

Before the Docker network feature, you could use the Docker link feature to allow containers to discover each other and securely transfer information about one container to another container

While links are still supported in this limited capacity, you should avoid them in preference of Docker networks. The link feature is expected to be deprecated and removed in a future release.


但是,我认为Docker链接功能为我们提供了自动服务发现,我无法找到解释该网络功能也可以做到的地方。我想念什么吗?
如果创建自己的桥接网络,并将Web容器和db容器连接到该网络,我的Web容器如何自动发现db容器?
当我说服务发现时,我的意思是某个容器可以使用<name>_PORT_<port>_<protocol>之类的东西在桥接功能中发现其他容器的服务IP地址和网桥网络中的端口。

最佳答案

新的网络功能仍将具有相同的功能。就像您使用旧的--link功能将它们链接一样,同一网络上的所有容器都将相互了解。因此,无需链接每个容器,您只需根据需要将它们放入小型网络中即可。

这种方法还摆脱了如果必须更新链接的容器会造成的旧的且相当烦人的链接中断。

关于docker - Docker网络功能如何提供服务发现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34689496/

相关文章:

linux - Docker 容器和主机中的不同文件所有者

go - 加速 golang vendor 的 docker 构建

docker - 在 ubuntu 中限制在 docker 上运行的端口

mysql - 容器初始化后如何连接到 docker-compose mysql?

django - 在kubernetes上使用Nginx和Gunicorn提供Django静态文件

Dockerfile:创建用户可以看到的ENV变量?

docker - Nginx使用Docker配置多个服务器端口

ruby - Debian Packagemanager 在构建 docker 镜像时不会在 alpine-linux 上安装 vagrant.deb 包

nginx - Docker nginx 无法连接到在单独容器中运行的上游 gunicorn

spring-boot - 如何显示通过哪个cassandra节点处理您的请求