DEV Community

Sanghun Yun
Sanghun Yun

Posted on Edited on Originally published at gearflowlab.com

How to Fix Docker DNS Resolution Failure in WSL2 ("Temporary Failure in Name Resolution")

Container builds on Windows 11 WSL2 frequently fail with Temporary failure in name resolution or getaddrinfo EAI_AGAIN even while host PowerShell nslookup works normally. WSL2's virtual NAT DNS stub drops forwarded UDP queries from nested Docker bridges (especially under split-tunnel VPNs), and Docker's embedded 127.0.0.11 resolver passes dead upstreams straight through.

Lab Resolver Timeout Findings (Docker Engine 27.3.1 on WSL2)

  • Runtime Divergence: Against an unreachable upstream (--dns 192.0.2.1), Alpine (musl) and Node threw EAI_AGAIN in 5s, Debian (glibc) failed in 10s, and npm view hung for 85s.
  • Silent Exit-0 Trap: On debian:bookworm-slim and ubuntu:24.04, apt-get update stalled 120s and exited with code 0, causing chained && apt-get install commands to fail immediately with exit 100.
  • Resolver Fix: Explicit resolvers in daemon.json restored fast lookups across builds and bridge containers.

Full daemon.json, .wslconfig Fix & Compose Converter

Top comments (0)