Docker inbuilt service discovery
The Docker platform inherently supports the service discovery for the containers that are attached to any user-defined network using an embedded Domain Name Service (DNS). This functionality has been added to Docker since the version 1.10
. The embedded DNS feature enables the Docker containers to discover each other using their names or aliases within the user-defined network. In other words, the name resolution request from the container is first sent to the embedded DNS. The user-defined network then uses a special 127.0.0.11
IP address for the embedded DNS, which is also listed in /etc/resolv.conf
.
The following example will help to gain a better understanding of Docker's built-in service discovery capability:
- Let's begin by creating a user-defined bridge network,
mybridge
, using the following command:
$ sudo docker network create mybridge
- Inspect the newly created network to understand the subnet range and gateway IP:
$ sudo docker network inspect mybridge...