两个或多个docker容器之间通过名字相互访问

JentZhang / 2023-08-09 / 原文

转自 两个或多个docker容器之间通过名字相互访问[https://zhuanlan.zhihu.com/p/258939355]

需要公用一个自定义网络

  • 官方特意解释了这两个网卡的区别

User-defined bridges provide automatic DNS resolution between containers.
Containers on the default bridge network can only access each other by IP addresses, unless you use the --link option, which is considered legacy. On a user-defined bridge network, containers can resolve each other by name or alias.