When nginx and web services are both running in the docker container, how does nginx load balance configure the IP address of the service

  docker, question

Nginx and web services are in the same docker swarm overlay network, so they can be accessed across hosts. However, when web services are deployed through swarm, the ip of the service is allocated only when the container is started, and the IP of these web services is not known before starting. This brings up a problem. How does nginx configure the address of the web service when acting as a reverse proxy?

If there is no exposed port
Use service name
If the port is exposed
The port can be exposed with local IP+