title: Using the host ip in docker-compose
body: <p>I want to create a <strong>docker-compose</strong> file that is able to run on different servers. </p>
  
  <p>For that I have to be able to specify the host-ip or hostname of the server (where all the containers are running) in several places in the <strong>docker-compose.yml</strong>. </p>
  
  <p>E.g. for a consul container where I want to define how the server can be found by fellow consul containers.</p>
  
  <pre><code>consul:
    image: progrium/consul
    command: -server -advertise 192.168.1.125 -bootstrap
  </code></pre>
  
  <p>I don't want to hardcode 192.168.1.125 obviously.</p>
  
  <p>I could use  <strong><a href="https://docs.docker.com/compose/env-file/" rel="noreferrer">env_file</a>:</strong> to specify the hostname or ip and adopt it on every server, so I have that information in one place and use that in docker-compose.yml. But this can only be used to specifiy environment variables and not for the advertise parameter.</p>
  
  <p>Is there a better solution?</p>