title: Java Spring will not talk to Consul when run as a Docker container
body: <p>I am trying to solve what I believe is a common use case for running micro services.  In this case I am testing consul with a spring cloud application. I am trying to test consul in two different ways.  The first of which is running in a docker container and the other is running on the docker host machine.  I am then attempting to start a spring cloud container that will talk with either consul example.</p>
  
  <p>I have been unable to make the spring cloud application talk to consul when the spring cloud application is run as a docker container.  When the spring cloud application is run with the host networking mode it works as it can resolve the localhost ports, but this is not an acceptable solution if I wish to run multiple instances of the image.  </p>
  
  <p>An example of my docker compose file when running both services as containers is shown below. Here I am attempting to set the consul uri in spring cloud through the environment variables, but have been unable to get it to work using a variety of configurations.  If anyone could point to an example of these functions working together that would be immensely helpful.</p>
  
  <pre><code> consul1:
    image: progrium/consul
    ports:
      - "8400:8400"
      - "8500:8500"
      - "8600:53/udp"
      - "8600:53/tcp"
    environment:
        GOMAXPROCS: 100
        entrypoint: "/bin/consul"
        hostname: consul
        command: agent -log-level=debug -server -config-dir=/config -bootstrap -ui-dir /ui
  
  simpletest:
      build: simpletest
      hostname: simpletest
      environment:  
        JAVA_OPTS: "-Xdebug -Xrunjdwp:server=y,transport=dt_socket,suspend=n -Dspring.cloud.consul.host=consul1"
      ports:
       - 39041:7051
       - 39052:7055
  #     d2fdockerroot_consul1_1 consul
  #    links:
  #     - consul1
  </code></pre>