DockerMid

Local DNS resolver found in resolv.conf and containers can't use it

Docker warns when the host resolver is on 127.0.0.1. Containers can't use it. Set the dns key in daemon.json or turn dnsmasq off.

What you see

  • WARNING: Local (127.0.0.1) DNS resolver found in resolv.conf and containers can't use it. Using default external servers : [8.8.8.8 8.8.4.4]
  • Containers can't resolve names that only your internal DNS knows

What it means

Many Linux desktops run a caching resolver such as dnsmasq on a loopback address like 127.0.0.1. A container has its own network namespace, so 127.0.0.1 inside it means the container itself, where no DNS server runs.

Docker detects this and falls back to public servers. That is enough for the internet but not for hostnames only your network resolves.

How to confirm the cause

  1. 1
    Check whether dnsmasq is involved
    ps aux | grep dnsmasq
  2. 2
    Test an internal name from a container
    docker run --rm -it alpine ping -c4 MY_INTERNAL_HOST

    If it fails but the host resolves it, the container is not using your internal DNS.

Causes and fixes

  • Host resolver is on a loopback address

    HOW TO TELL
    The warning appears and dnsmasq is running.
    FIX
    Pick one: tell Docker which DNS servers to use, or turn off dnsmasq. If your internal DNS cannot resolve public names, include at least one server that can, so Docker Hub and internet names still work.
    # /etc/docker/daemon.json
    {
      "dns": ["8.8.8.8", "8.8.4.4"]
    }
    
    sudo service docker restart
    docker pull hello-world

How to stop it coming back

  • Set dns in daemon.json on hosts with a loopback resolver, and document it for the team.

Keep going

Sources

Docker documentation (docs.docker.com), read 18 Nov 2026 from the official docs repository.

Search

Search cheat sheets and projects