I'm running a Docker container which clones some git repositories and builds a project inside of itself.

It clones code from 2 different repositories: one is public github.com and the other one is private my.companys.github.enterprise.net and is only accessible through VPN.

In my resolv.conf I have 2 nameservers: one for public services and one for VPN:


When I try to clone repositories inside my docker container it can only resolve github.com repositories and can't resolve my.companys.github.enterprise.net repositories.

If I switch around the lines in my resolv.conf, then it can only resolve my.companys.github.enterprise.net and not the github.com ones.

Is there a way to allow Docker to resolve both links to repositories using 2 different nameservers from resolv.conf instead of just trying the first one?

  • 1
    Maybe you can set in your company's DNS a forwarder (the internet DNS as a forwarder I mean) and setting it in first place you can resolve all. If not possible to modify the company DNS server... not sure how to solve. Dec 15, 2016 at 17:31
  • If the first nameserver answers AT ALL (even with "I don't know that name/address"), then the next one will not be checked. @OscarAkaElvis' suggestion in his comment is spot-on. Dec 15, 2016 at 18:56

1 Answer 1


Your confusion is that nameserver entries in /etc/resolv.conf are assumed to be equivalent (i.e., mirrors, and will provide the same answers no matter which one is asked). If one nameserver responds with "that doesn't exist", the resolution code is done, it does not try other nameservers looking for a different answer. The resolver code is in libc and is very simple.

The easiest solution to fix this is to run a local nameserver in Docker (BIND or unbound packages) that has the smarts to know about the public name space and the "alternate universe" that is your private name space, usually configured by using forwarding or "stub" zones. Google is your friend to set that up. Then have just one nameserver entry in /etc/resolv.conf that points to

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .