docker dns用于运行容器集

时间:2018-04-25 22:07:16

标签: docker dns docker-compose containers

我有一个docker镜像,它在$ PORT上提供给定的服务。

当使用docker-compose运行此容器的多个实例时,我可以使用dig访问网络内部的所有ip(其他dns工具可用)。

如何从docker命令行客户端和python库中获得相同的结果?

1 个答案:

答案 0 :(得分:1)

实现此目的的一种方法是使用别名connect the docker containers to a network,您可以使用相同的别名将多个容器连接到同一网络,然后可以在对dns查找的响应中看到这些。

BluetoothProfile.STATE_DISCONNECTED

现在,当您将另一个容器连接到该网络时,您可以看到它们在域$ docker create network --name test-nwk $ docker run --name test-service-1 busybox $ docker run --name test-service-w busybox $ docker network connect test-nwk test-service-1 --alias test-service $ docker network connect test-nwk test-service-2 --alias test-service

中都可见
test-service