Service Discovery in 1.12: How do I discover other containers of a service from within a container

With docker compose, each replica of a service has the <service_name>_# pattern. So you could then ping other nodes using the dns names mongodb_1, mongodb_2 etc.

Using the .dab file to create a stack, which creates the services.

The resulting services seem to get totally random network names. I am looking for a way to refer to the other nodes of the service from within another node.

And while yes, the DNS will round robin off of _, I really want to get the ip of the first node that was created.