Get container IP within Compose

I’m trying to set up a Consul cluster using Compose on a Swarm cluster with an overlay network. The issue is that Consul has to be started with a "–advertise " parameter which tells it what IP to use for cluster configuration. Problem is, I don’t know that until runtime. Is there a way in a Compose file to get the IP of a container at runtime?

I’d prefer to just be able to natively run ‘docker-compose up’ without having to use something like sed to edit the Compose file at runtime.

Thanks!