Docker uses DNS for service discovery, so containers can find one another with standard networking. Applications use server names in their client connection configuration, and when the application makes a DNS query to find the target, Docker responds with the container's IP address. It's the same in Docker Swarm when your target server name could actually be the name of a Docker service running with dozens of replicas across the cluster.
There are two ways for Docker to respond to manage DNS for a service with multiple replicas. The default is to use VIP: a virtual IP address. Docker uses a single IP address for the service, and relies on the networking stack in the host operating system to route a request ...