How to Do Service Discovery when DockersSwarm Uses overlay Network

  docker, question

For example, service A calls service B. After deployment, A and B are in an overlay network. How does A know B’s IP

docker service create --network docker-net --name mysql mysql
 docker service create --network docker-net --name webapp mywebapp:3.0

In this way, mysql:3306 can be directly used in the webapp service to access mysql