Search code examples
dockerdnsdebian

Docker nslookup works but not wget


I have the following setup:

  • a dns server with an A entry for myhost1.mycompany -> 10.10.10.1
  • a server myhost2 (debian11) with docker daemon (20.10.5) installed and a runing container mycontainer1 on it
  • on myhost2, the private dns server is configured in /etc/resolv.conf with search mycompany

On myhost2:

  • nslookup myhost1 -> 10.10.10.1
  • ping myhost1 -> works
  • wget myhost1 -> wokrs
  • wget google.com -> works

On mycontainer1:

  • nslookup myhost1 -> 10.10.10.1
  • ping myhost1 -> bad address
  • wget myhost1 -> bad address
  • wget google.com -> works
  • cat /etc/resolv.conf -> same output as cat /etc/resolv.conf on myhost2

So this is not (I guess) a DNS issue as nslookup queries work fine from the container, but I can't figure out why other application (like ping or wget) can't get the resolved ip..

Thanks for sharing your ideas !


Solution

  • That behavior may be caused by the option ndots:0 in /etc/resolv.conf which prevents ping from adding your default local domain.

    In this situation, ping myhost1.mydomain.lan should work, where ping myhost1 should not (and the same with wget).

    So I suggest you can try to change it to ndots:5.

    For example :

    nameserver 127.0.0.11
    options ndots:5