title: How to tell docker to use host dns configuration?
body: <p>I am working behind a company proxy.
  Because of the many limitations enforced, I have to switch to public network when I come to build my docker images (mainly ubuntu-based images). The build is performed on the same computer (thus, the same dns conf).</p>
  
  <p>Apart from the build, I always run my containers behind this proxy.
  The company also (and indeed) has its own dns.</p>
  
  <p>Unfortunately, I don't understand how to pass the host dns to the containers the "proper way" and don't understand how docker manages to build the containers resolv.conf.</p>
  
  <p>When I look at my host, I see such a conf :</p>
  
  <blockquote>
    <p>$ cat /etc/resolv.conf</p>
  </blockquote>
  
  <pre><code>nameserver 8.8.8.8
  nameserver 8.8.8.4
  nameserver 10.xxx.yyy.z
  search rennes.mycompany.fr
  </code></pre>
  
  <p>And from within my containers, I see:</p>
  
  <pre><code>search rennes.mycompany.fr
  nameserver 127.0.0.11
  options ndots:0
  </code></pre>
  
  <p>What looks odd to me is that only a part of the host configuration can be found in the container... 
  And when I try to reach any company-hosted name from the container, I have a name resolution failure.</p>
  
  <p>But if I add the host's resolv.conf nameserver to the container's one, it works:</p>
  
  <blockquote>
    <p>$ echo nameserver 192.168.1.1 >> /etc/resolv.conf</p>
  </blockquote>
  
  <p>So, this is indeed not the way to do it... but I am not sure how I should perform it.
  I tried to add the <a href="https://docs.docker.com/compose/compose-file/#dns" rel="noreferrer">'dns'</a> to my services in the docker-compose, but I didn't work (or not a way I understand), and the documentation there is quite spartan...</p>
  
  <p>Is there a way to tell docker to use/share host's dns configuration? 
  May my problem come from my building the image outside of the company network?</p>
  
  <p><strong>EDIT:</strong> <em>the docker-compose.yml</em> </p>
  
  <pre><code>version: '3.3'
  services:
    my-apache:
      image: apache:latest
      ports:
        - 8088:80
      networks:
        - my-project-net
      dns: 
        - 192.168.1.1
      depends_on:
        - my-project
    my-project:
      image: my-project:latest
      networks:
        - my-project-net
      dns: 
        - 192.168.1.1
  
  networks:
    my-project-net:
      driver: bridge
  </code></pre>
  
  <p>only 'my-project' requires access to company dns, but I added dns to both in case I missed some clue...</p>
  
  <p><strong>EDIT 2 :</strong> few more details and attempts</p>
  
  <ul>
  <li>docker version : 18.03.0-ce, build 0520e24</li>
  <li>docker-compose version : 1.18.0, build 8dd22a9</li>
  </ul>
  
  <p>The name I try to resolve looks like this :</p>
  
  <blockquote>
    <p>some-pf-db.network.mycompany.fr</p>
  </blockquote>
  
  <p>The (modified) docker daemon conf looks like this : </p>
  
  <blockquote>
    <p>$ cat /etc/docker/daemon.json :</p>
  </blockquote>
  
  <pre><code>{
      "insecure-registries": [
          "some.test.registry.mycompany.fr:5000"
      ],
      "log-driver": "json-file",
      "log-opts": {
          "max-file": "3",
          "max-size": "10m"
      },
      "dns-opts": ["ndots:15"]
  }
  </code></pre>
  
  <p>Following @BMitch <a href="https://github.com/moby/moby/issues/32093" rel="noreferrer">link</a>, I tried to update docker daemon (+restart) with the ndots options up to 15 (don't think I'd need that many, but it's the lazy way!)... 
  <s>and unfortunately it didn't solve the problem. The new value replaces the former one within the container, but it keeps failing reaching the dns</p>
  
  <blockquote>
    <p>could not translate host name "some-pf-db.network.mycompany.fr" to
    address: Temporary failure in name resolution
    </s></p>
  </blockquote>
  
  <p><strong>EDIT3 :</strong> I was looking at the wrong container... so, changing the threshold for dots (ndots) up to (eg.) 15 within the docker daemon conf (/etc/docker/daemon.json) AND removing the "dns" param from the service makes the magic operate! I have now access to my company dns for names (with a lot of dots in them!!)</p>