title: Docker-compose container using host DNS server
body: <p>I'm running several containers on my "Ubuntu 16.10 Server" in a "custom" bridge network with compose 2.9 (in a yml version 2.1). Most of my containers are internally using the same ports, so there is no way for me to use the "host" network driver.
  My containers are all links together, using the dedicated <code>links</code> attribute.</p>
  
  <p>But, I also need to access services exposed outside of my containers. These services have dedicated URL with names registered in my company's DNS server.
  While I have no problem to use public DNS and reach any public service from within my containers, I just can't reach my private DNS.</p>
  
  <p>Do you know a working solution to use private DNS from a container? Or even better, use host's network DNS configuration?</p>
  
  <p>PS: Of course, I can link to my company's services using the <code>extra_hosts</code> attribute in my services in my docker-compose.yml file. But... that's definitively not the goal of having a DNS. I don't want to register all my services in my YML file, and I don't want to update it each time services' IP are updated in my company.</p>
  
  <p><strong>Context :</strong></p>
  
  <ul>
  <li>Host: Ubuntu 16.10 server </li>
  <li>Docker Engine: 1.12.6 </li>
  <li>Docker Compose: 1.9.0 </li>
  <li>docker-compose.yml: 2.1 </li>
  <li>Network: Own bridge.</li>
  </ul>
  
  <p><strong>docker-compose.yml file (extract):</strong></p>
  
  <pre><code>version: '2.1'
    services:
      nexus:
      image: sonatype/nexus3:$NEXUS_VERSION
      container_name: nexus
      restart: always
      hostname: nexus.$URL
      ports:
        - "$NEXUS_81:8081"
        - "$NEXUS_443:8443"
      extra_hosts:
        - "repos.private.network:192.168.200.200"
      dns:
        - 192.168.3.7
        - 192.168.111.1
        - 192.168.10.5
        - 192.168.10.15
      volumes_from:
        - nexus-data
      networks:
        - pic
  
    networks:
      pic:
        driver: bridge
        ipam:
          driver: default
          config:
            - subnet: 172.18.0.0/16
              gateway: 172.18.0.1
  </code></pre>
  
  <p>I tried with and without the <code>ipam</code> configuration for the <code>pic</code> network, without any luck.</p>
  
  <p><strong>Tests &amp; Results:</strong>
  <code>docker exec -ti nexus curl repos.private.network</code>
  returns properly the HTML page served by this service</p>
  
  <p><code>docker exec -ti nexus curl another-service.private.network</code>
  Returns <code>curl: (6) Could not resolve host: another-service.private.network; Name or service not known</code>
  While <code>curl another-service.private.network</code> from the host returns the appropriate HTML page.</p>
  
  <p>And "of course" <code>another-service.private.network</code> is known in my 4 DNS servers (192.168.3.7, 192.168.111.1, 192.168.10.5, 192.168.10.15).</p>