As well as core networking,
libnetwork also provides some important network services.
Service discovery allows all containers and Swarm services to locate each other by name. The only requirement is that they be on the same network.
Under the hood, this leverages Docker’s embedded DNS server and the DNS resolver in each container. The figure below shows container “c1” pinging container “c2” by name. The same principle applies to Swarm Services.