title: Docker for Mac Container to Host Networking - Consul Health Checks Connection Refused
body: <p>I have a HTTP health check in my service, exposed on <code>localhost:35000/health</code>. At the moment it always returns <code>200 OK</code>. The configuration for the health check is done programmatically via the HTTP API rather than with a service config, but in essence, it is:</p>
  
  <pre><code>set id: service-id
  set name: health check
  set notes: consul does a GET to '/health' every 30 seconds
  set http: http://127.0.0.1:35000/health
  set interval: 30s
  </code></pre>
  
  <p>When I run consul in dev mode (<code>consul agent -dev -ui</code>) on my host machine directly the health check passes without any problem. However, when I run consul in a docker container, the health check fails with:</p>
  
  <pre><code>2017/07/08 09:33:28 [WARN] agent: http request failed 'http://127.0.0.1:35000/health': Get http://127.0.0.1:35000/health: dial tcp 127.0.0.1:35000: getsockopt: connection refused
  </code></pre>
  
  <p>The docker container launches consul, as far as I am aware, in exaclty the same state as the host version:</p>
  
  <pre><code>version: '2'
  services:
    consul-dev:
      image: "consul:latest"
      container_name: "net-sci_discovery-service_consul-dev"
      hostname: "consul-dev"
      ports:
        - "8400:8400"
        - "8500:8500"
        - "8600:8600"
      volumes:
        - ./etc/consul.d:/etc/consul.d
      command: "agent -dev -ui -client=0.0.0.0 -config-dir=/etc/consul.d"
  </code></pre>
  
  <p>I'm guessing the problem is that consul is trying to do the GET request to the containers loopback interface rather than what I am intending, which is for the loopback interface of the host. Is that a correct assumption? More importantly, what do I need to do to correct the problem?</p>