Docker swarm, Consul and Spring Boot
<p>I have 6 microservices packed in docker containers. On every swarm node, i have installed consul agent, binded to host ip, and client in 0.0.0.0 mode.
All microservices are in docker-compose file which I am running from Swarm manager. 
Microservices are written in Java and in bootstrap.yml I must to specify consul agent endpoint. Possible choices are:</p>

<ul>
<li>localhost</li>
<li>${HOSTIP} environment variable</li>
</ul>

<p>Problems:
 - localhost is not localhost of host, but container localhost, and I don't have consul agent on container localhost but host.
 - ${HOSTIP} in compose file i have to supply this env var. But, I don't know where Swarm MAnager will schedule microservice start so I cannot know which IP address will be used. </p>

<p>I tried to expose on each node host ip address but since i am running compose from manager, it will not read this variable. </p>

<p>Do you have any proposal how to solve this? I have consul cluster, 3 managers and 3 nodes. on each manager and node i have consul agent started (as docker container). No matter what type of networking i am using, i am not able to start up microservice. I started consul as --net=host and --net=bridge, but this is not working.</p>

<p>Is there anyone with some idea?
Thanks ahead.</p>