title: Docker custom dns resolve among containers
body: <p>I have following <code>docker-compose.yml</code></p>
  
  <pre><code>php:
      build: ./phpfpm
      volumes:
          - ~/works/codes:/code
  
  web:
      image: nginx:latest
      ports:
          - "80:80"
      volumes:
          - ~/works/codes:/code
          - ./nginx/etc/conf.d/virtual.conf:/etc/nginx/conf.d/virtual.conf
          - ./nginx/var/log/nginx:/var/log/nginx
      links:
          - php
  </code></pre>
  
  <p>I've 2 virtual hosts setup inside web container</p>
  
  <pre><code>app.lan
  api.lan
  </code></pre>
  
  <p>In my <code>php</code> application I do curl to <code>api.lan</code>. But it throws <code>Could not resolve host: api.lan</code></p>
  
  <p>In my docker host I've added following to <code>/etc/hosts</code> file</p>
  
  <pre><code>127.0.0.1 app.lan
  127.0.0.1 api.lan
  </code></pre>
  
  <p>I can curl from docker host machine to <code>api.lan</code> without a problem. But seems <code>web</code> container doesn't resolve name from docker host machine.</p>
  
  <p>If I find the <code>web</code> container's ip and put that into the php container's hosts file as follows it works.</p>
  
  <pre><code>172.18.0.5 api.lan
  </code></pre>
  
  <p>But how do I automate this on docker compose. Or any other best practices for this?</p>
  
  <p>In addition if I cat <code>/etc/resolve.conf</code> of either container I can find following.</p>
  
  <pre><code>search local
  nameserver 127.0.0.11
  options ndots:0
  </code></pre>
  
  <p>What's this 127.0.0.11? Is it the host machine?</p>
  
  <p>I'm on "Docker for mac" <code>v 1.12.1</code></p>