To see how container DNS failures behave on WSL 2, I ran containers on Docker Desktop for Windows 11 (WSL 2 backend, Docker Engine 27.3.1) with an unreachable DNS server (--dns 192.0.2.1) and with a working one (--dns 1.1.1.1). With 192.0.2.1, Python on Debian (glibc) failed after 10 seconds with Temporary failure in name resolution; Python on Alpine (musl) failed after 5 seconds with Try again; Node threw EAI_AGAIN after 5 seconds; curl exited 6 after 11 seconds; and npm view express version took 85 seconds before reporting EAI_AGAIN.
In both debian:bookworm-slim and ubuntu:24.04, apt-get update printed Temporary failure resolving, took 120 seconds, and exited with code 0, so a chained && apt-get install -y curl ran anyway and failed immediately with E: Unable to locate package curl (exit 100). On a user-defined network, /etc/resolv.conf kept nameserver 127.0.0.11, and Docker's embedded DNS server passed the dead upstream straight through and timed out in the same 5 seconds.
Direct Answer: Fix Docker WSL 2 Temporary failure resolving and Node EAI_AGAIN DNS timeouts by testing docker run --rm --dns 1.1.1.1 alpine:3.20 nslookup deb.debian.org, then configuring reachable upstream resolvers in Docker Compose dns: or /etc/docker/daemon.json. On corporate split-tunnel VPNs, also enable dnsTunneling=true under [wsl2] in %USERPROFILE%\.wslconfig and restart WSL.
| Container Symptom / Error | Container /etc/resolv.conf | Root Cause in Docker / WSL 2 | Permanent Fix |
|---|---|---|---|
Temporary failure resolving (apt 120s stall) or Node EAI_AGAIN (5s) | nameserver 192.168.65.7 or 127.0.0.11 | Upstream Windows / WSL 2 forwarder unreachable or dead Wi-Fi switch | Add dns: [1.1.1.1, 8.8.8.8] in Compose or "dns" in daemon.json |
1.1.1.1 times out on corporate VPN, intranet names fail | Fallback [8.8.8.8, 8.8.4.4] | VPN firewall blocks external UDP port 53 and hides split-DNS resolvers | Set internal VPN DNS IPs in daemon.json + dnsTunneling=true in .wslconfig |
WSL 2 Ubuntu shell itself prints Network is unreachable | Broken /etc/resolv.conf symlink in WSL | Corrupted Hyper-V virtual switch NAT or disabled auto-generation | Enable dnsTunneling=true under [wsl2] and run wsl.exe --shutdown |
Peer container hostname fails while deb.debian.org resolves | nameserver 192.168.65.7 (default bridge) | Default docker0 bridge disables embedded service-name DNS | Move containers onto a user-defined Docker Compose bridge network |
Migrating standalone docker run --dns 1.1.1.1 flags into a multi-container stack? Generate the exact Compose dns: and custom bridge YAML with our Docker Run to Compose Converter.
Look at the nameserver, then give the container one that answers
First check what DNS server the container is trying to use, and test whether giving it a reachable server fixes the lookup:
# 1. See what /etc/resolv.conf looks like inside a container
docker run --rm alpine:3.20 cat /etc/resolv.conf
# 2. Test a lookup with an explicit reachable DNS server
docker run --rm --dns=1.1.1.1 alpine:3.20 nslookup deb.debian.org
If the second command works while a plain docker run --rm alpine:3.20 nslookup deb.debian.org times out, set dns on the container or in Docker Compose:
services:
web:
image: alpine:3.20
dns:
- 1.1.1.1
- 8.8.8.8


127.0.0.11 DNS server; overriding dead WSL2/VPN stub resolvers in /etc/docker/daemon.json or enabling dnsTunneling=true eliminates 5-second lookup stalls.If your workstation or corporate VPN requires internal company DNS resolvers to resolve private intranet hostnames (or blocks outbound UDP port 53 to public resolvers altogether), list your company's internal DNS server IPs instead of 1.1.1.1 and 8.8.8.8. When you run Docker Engine installed directly inside a WSL 2 Linux distribution (rather than Docker Desktop), you can set those default resolvers once for the entire daemon in /etc/docker/daemon.json:
sudo tee /etc/docker/daemon.json <<'EOF'
{
"dns": ["1.1.1.1", "8.8.8.8"]
}
EOF
sudo systemctl restart docker
If DNS is broken inside the WSL 2 Linux distribution itself (not only inside Docker containers) on Windows 11 22H2 or 23H2, check that WSL DNS tunneling is enabled in %USERPROFILE%\.wslconfig on the Windows host and restart WSL from PowerShell:
# C:\Users\<your-username>\.wslconfig
[wsl2]
dnsTunneling=true
wsl.exe --shutdown
Note that on Official Docker Desktop, containers on the default bridge receive nameserver 192.168.65.7 while containers on user-defined or Compose networks receive nameserver 127.0.0.11 with upstream resolvers listed under # ExtServers:

Alpine's nslookup gave up after 5 seconds on both networks
On my Windows 11 Pro 23H2 machine running Official Docker Desktop (Docker Engine 27.3.1, WSL 2 backend kernel 6.6.87.2-microsoft-standard-WSL2), normal container DNS lookups were healthy out of the box. To observe and time how containers behave when their upstream DNS resolver stops answering (as happens when a corporate VPN rewrites host routes or a Windows firewall policy drops NAT UDP port 53 packets) the test run on 2025-01-26 passed --dns 192.0.2.1.
Address 192.0.2.1 belongs to 192.0.2.0/24 (TEST-NET-1 in RFC 5737), a documentation-only IPv4 range that is never routed on the public internet, so UDP port 53 queries sent to it receive no reply and force a clean resolver timeout across both default bridge and user-defined networks:

The five test cases in that capture highlight three behaviors that matter whenever you debug container DNS on WSL 2:
- Default bridge vs user-defined network (Cases A and B): On the default
bridgenetwork,/etc/resolv.confinside the container hadnameserver 192.168.65.7(Docker Desktop's internal VM forwarder). On a user-defined bridge network, it hadnameserver 127.0.0.11andoptions ndots:0. - A
RUN echointo/etc/resolv.confduringdocker buildwas gone at run time (Case C): Appendingoptions single-request-reopenwithRUN echo 'options single-request-reopen' >> /etc/resolv.confin aDockerfilemodified the file only during that single build step. When a container started from the built image, Docker bind-mounted a freshly generated/etc/resolv.conf(nameserver 192.168.65.7), wiping out the build-time line. - 5-second timeout on both networks (Cases D and E): With
--dns 192.0.2.1, Alpine'snslookup deb.debian.orgprinted;; connection timed out; no servers could be reachedand exited1after 5 seconds on both the default bridge and the user-defined network.
Each runtime words the failure differently, and npm takes 85 s
When I pointed seven common container tools at the same unreachable resolver (--dns 192.0.2.1), every tool failed, but each C library and language runtime printed a different error message and waited for a different multiple of the 5-second base timeout (distinct from mid-download TCP stalls after DNS succeeds, which trigger 15-second socket timeouts in Python pip ReadTimeoutError & wheel caching):

| Image / Tool | Command Tested | Error Text Returned | Time to Fail |
|---|---|---|---|
python:3.13-slim (Debian glibc) |
socket.getaddrinfo('deb.debian.org', 443) |
gaierror(-3, 'Temporary failure in name resolution') |
10.0 s |
python:3.13-alpine (Alpine musl) |
socket.getaddrinfo('deb.debian.org', 443) |
gaierror(-3, 'Try again') |
5.0 s |
node:22-alpine |
dns.lookup('registry.npmjs.org', ...) |
Error: getaddrinfo EAI_AGAIN |
5.0 s |
node:22-alpine (npm) |
npm view express version |
npm error code EAI_AGAIN |
85 s |
alpine:3.20 |
ping -c 1 google.com |
ping: bad address 'google.com' (exit=1) |
5.0 s |
debian:bookworm-slim |
getent hosts google.com |
(no output, exit=2) |
20 s |
alpine + curl |
curl -sS https://deb.debian.org |
curl: (6) Could not resolve host: deb.debian.org (Timeout while contacting DNS servers) |
11 s |
Notice that Temporary failure in name resolution (Debian glibc), Try again (Alpine musl), and EAI_AGAIN (Node.js) are all the exact same underlying resolver return code (EAI_AGAIN = -3); only the human-readable string from gai_strerror() differs between glibc and musl. And because npm retries failed registry lookups with exponential backoff for 85 seconds before printing npm error code EAI_AGAIN, a broken container DNS configuration during npm install or npm ci often looks like a frozen network hang rather than a DNS failure:

# Docker Desktop (Engine 27.3.1), Windows 11. 192.0.2.1 = unreachable test resolver. From dns2078b-20250124.txt
network --dns container nameserver result
default bridge 192.0.2.1 192.0.2.1 exit=1 after 5s
default bridge 1.1.1.1 1.1.1.1 exit=0 after 0s
user network 192.0.2.1 127.0.0.11 exit=1 after 5s
user network 1.1.1.1 127.0.0.11 exit=0 after 0s
apt-get update exits 0, and the next line fails
One of the most confusing symptoms of a Docker DNS outage happens inside Debian and Ubuntu image builds or container startup scripts that chain apt-get update && apt-get install -y .... Here is what happened when I ran that exact chain in debian:bookworm-slim and ubuntu:24.04 with --dns 192.0.2.1:
=== debian:bookworm-slim, --dns 192.0.2.1 ===
Err:1 http://deb.debian.org/debian bookworm InRelease
Temporary failure resolving 'deb.debian.org'
Err:2 http://deb.debian.org/debian bookworm-updates InRelease
Temporary failure resolving 'deb.debian.org'
Err:3 http://deb.debian.org/debian-security bookworm-security InRelease
Temporary failure resolving 'deb.debian.org'
Reading package lists...
W: Failed to fetch http://deb.debian.org/debian/dists/bookworm/InRelease Temporary failure resolving 'deb.debian.org'
W: Some index files failed to download. They have been ignored, or old ones used instead.
apt-get update exit=0 seconds=120
Reading package lists...
Building dependency tree...
E: Unable to locate package curl
apt-get install curl exit=100 seconds=0

Look closely at the exit codes and timings in that output:
apt-get updatewaited 120 seconds and exited0: Even though every single repository index failed withTemporary failure resolving 'deb.debian.org'(or'archive.ubuntu.com'and'security.ubuntu.com'onubuntu:24.04),apt-get updatetreated the failed downloads as warnings (W: Failed to fetch...) and returned exit status0after 2 minutes.- The
&&chain did not stop: Becauseapt-get updateexited0, the shell immediately executedapt-get install -y --no-install-recommends curl. Since the official base images ship with an empty/var/lib/apt/lists/directory,apt-get installfound zero package metadata and exited immediately (0 seconds, exit code100) withE: Unable to locate package curl. If you only read the final red error line at the bottom of a CI log, it looks like a missing package or bad repository mirror rather than a DNS failure two minutes earlier. - With a reachable DNS server, the whole sequence took 3 seconds: On the normal Docker Desktop bridge (
192.168.65.7) or with--dns 1.1.1.1,apt-get updatefinished in 1 second (exit=0) andapt-get install -y --no-install-recommends curlfinished in 2 seconds (exit=0).
Note that I ran these tests with docker run so I could pass --dns directly; docker build does not accept a per-build --dns CLI flag and instead uses the Docker daemon's DNS configuration:

Where a container's nameserver comes from on WSL2
Before changing configuration files, check which of the two WSL 2 Docker setups you are running, Official Docker Desktop for Windows (with the WSL 2 backend enabled) or Docker Engine installed directly inside a WSL 2 Linux distribution (such as Ubuntu), because they wire container DNS through two different paths:
DOCKER DESKTOP (what I tested)
container on default bridge --> /etc/resolv.conf has nameserver 192.168.65.7
container on user network --> /etc/resolv.conf has nameserver 127.0.0.11
(Docker's embedded DNS server, forwards upstream)
Note: Microsoft's WSL networking docs state that Docker Desktop containers
bypass WSL DNS tunneling.
DOCKER ENGINE INSIDE A WSL DISTRO (from Docker & Microsoft docs)
container on default bridge --> Docker copies the distro's /etc/resolv.conf,
strips 127.0.0.53 if present, or falls back
to 8.8.8.8 / 8.8.4.4.
distro /etc/resolv.conf --> written by WSL:
- DNS tunneling on (default): 10.255.255.254
- NAT mode without tunneling: Windows host vSwitch
Here is the healthy baseline on Docker Desktop showing how /etc/resolv.conf switches from 192.168.65.7 on the default bridge to 127.0.0.11 as soon as you attach the container to a user-defined network (gfl-dnsnet):

NAT mode, firewalls and VPNs (from Microsoft's docs)
When Docker Engine runs inside a WSL 2 distribution and the distro uses legacy NAT mode without DNS tunneling, WSL writes the Windows host's Hyper-V virtual switch IP into the distro's /etc/resolv.conf and forwards UDP port 53 traffic across that virtual switch. Microsoft's WSL troubleshooting documentation notes two host-level settings that frequently block those NAT DNS packets:
- Windows Firewall Group Policy rules blocking virtual switch rules: WSL's host networking service (HNS) creates a local Windows Firewall rule to allow DNS traffic from the Hyper-V virtual switch. If enterprise Group Policy sets
AllowLocalFirewallRules : FalseorAllowInboundRules : False(checked viaGet-NetFirewallProfile -PolicyStore ActiveStorein PowerShell), Windows drops inbound UDP port 53 packets from the WSL 2 subnet. - Corporate VPN clients (Cisco AnyConnect, GlobalProtect, Zscaler): Many VPN clients modify Windows interface metrics, install Name Resolution Policy Table (NRPT) rules, or block split-tunnel traffic from secondary local subnets, causing NAT DNS packets from WSL 2 to black-hole as soon as the VPN connects.
Centralizing container logs in a log stream such as OpenObserve (:5080) makes this pattern immediately visible across microservices, every runtime fails at a multiple of 5 seconds until a reachable resolver is configured:

systemd-resolved, 127.0.0.53 and the 8.8.8.8 fallback
If you run Docker Engine directly inside an Ubuntu WSL distribution where systemd is enabled, systemd-resolved manages host DNS and points /etc/resolv.conf at its local loopback stub listener: nameserver 127.0.0.53. When you start a container without explicit --dns flags, Docker builds the container's /etc/resolv.conf from the host file, but it cannot leave 127.0.0.53 inside the container.
Because each bridge container has its own isolated network namespace (netns) with its own private lo loopback interface, sending a DNS query to 127.0.0.53 inside the container queries the container itself (where systemd-resolved is not running), not the WSL host. According to Docker's networking documentation, when Docker sees 127.0.0.53 on the host, it checks /run/systemd/resolve/resolv.conf for real upstream DNS servers. If no non-loopback nameserver remains after filtering, Docker logs No non-localhost DNS nameservers are left in resolv.conf. Using default external servers : [nameserver 8.8.8.8 nameserver 8.8.4.4] and writes Google's public DNS into the container, which immediately times out on corporate networks that block external UDP port 53:

127.0.0.11 passed the dead upstream straight through
On the default bridge network, Docker writes the upstream DNS servers directly into the container's /etc/resolv.conf. On any user-defined bridge network, including the network that docker compose up creates automatically for a Compose project, Docker instead writes nameserver 127.0.0.11 so containers on the same network can resolve each other by service name (for example, postgres or gfl-redis).
A common misconception is that switching from the default bridge to a user-defined Compose network will by itself cure external DNS failures. When a container queries 127.0.0.11:53 for a name that does not match any container on the attached bridge network, Docker's embedded DNS server forwards the query to the external resolvers listed in the # ExtServers: [...] comment of /etc/resolv.conf. In my test with --network gfl-dnsnet --dns 192.0.2.1, 127.0.0.11 resolved the peer container gfl-redis locally in 2 milliseconds, and then passed the external query for deb.debian.org straight through to 192.0.2.1 and timed out after the exact same 5 seconds:

musl read timeout and attempts, but the total wasn't the product
Alpine Linux containers use musl libc instead of GNU glibc. In earlier versions of musl, the resolver queried configured nameservers in parallel and did not implement glibc's single-request or single-request-reopen workarounds for NAT firewalls that drop one packet when IPv4 (A) and IPv6 (AAAA) UDP queries are sent simultaneously from the same source socket.
Even on current Alpine images (python:3.13-alpine, musl 1.2.5), musl and glibc handle /etc/resolv.conf timeout options differently. When I tested socket.getaddrinfo against the unreachable resolver --dns 192.0.2.1 with --dns-opt flags, musl did read timeout and attempts, but its total wait time was bounded by its overall query window rather than multiplying timeout × attempts:
- No
--dns-optflags:python:3.13-alpine(musl) failed after 5.0 seconds withgaierror(-3, 'Try again'), whilepython:3.13-slim(glibc) failed after 10.0 seconds (2 attempts × 5 seconds). --dns-opt timeout:1 --dns-opt attempts:1: Bothmuslandglibcfailed after 1.0 second.--dns-opt timeout:2 --dns-opt attempts:3:muslfailed after 2.0 seconds (not 6.0 seconds), becausemuslusestimeoutand retry intervals inside a bounded overall query window rather than waiting sequentially fortimeout × attempts.

Four checks to find where it breaks
Run these four checks in order to separate a broken IP route, a bad container /etc/resolv.conf, a blocked outbound UDP port 53, and a broken WSL distro resolver:
Step 1: Does plain IP traffic get out?
docker run --rm alpine:3.20 ping -c 2 1.1.1.1
If ping 1.1.1.1 fails with 100% packet loss or Network is unreachable, the container cannot route IPv4 packets to the internet at all; fix container routing or VPN split-tunnel rules before debugging DNS.
Step 2: Read the container's /etc/resolv.conf
docker run --rm alpine:3.20 cat /etc/resolv.conf
nameserver 192.168.65.7: Normal on Official Docker Desktop's default bridge network.nameserver 127.0.0.11: Normal on a user-defined or Docker Compose network; look at the# ExtServers: [...]comment line to see which upstream DNS servers Docker is actually forwarding external queries to.nameserver 8.8.8.8(when you didn't configure it): Docker stripped a loopback address such as127.0.0.53from the host's/etc/resolv.confand fell back to Google DNS, which fails if your corporate network blocks external UDP port 53.
Step 3: Ask a DNS server directly
docker run --rm alpine:3.20 nslookup deb.debian.org 1.1.1.1
Passing 1.1.1.1 as the second argument tells nslookup to ignore /etc/resolv.conf and query 1.1.1.1:53 directly. If this succeeds while a plain nslookup deb.debian.org fails, outbound UDP port 53 works and you only need to configure a working nameserver in Solution 1 or Solution 2:

Step 4 (Docker Engine in a distro): check the distro itself
If you run Docker Engine installed directly inside a WSL 2 Linux distribution (not Docker Desktop), run the same two checks inside the WSL shell itself:
cat /etc/resolv.conf
nslookup google.com
With WSL DNS tunneling enabled on Windows 11 (the default in current WSL 2 releases), the distro's /etc/resolv.conf normally shows nameserver 10.255.255.254. If nslookup google.com fails inside the WSL distribution too, fix WSL's own DNS first using Solution 3 or Solution 4 below; if the WSL distribution resolves names cleanly while containers fail, configure Docker's daemon DNS in Solution 2.
Fixes, from one container up to all of WSL
Solution 1: A reachable DNS server per container or Compose service (tested)
Passing explicit DNS servers on the container or Compose service works on both Official Docker Desktop and Docker Engine inside a WSL distribution, and it does not require restarting the Docker daemon.
Fix 1.1: docker run flags
docker run --rm \
--dns=1.1.1.1 \
--dns=8.8.8.8 \
--dns-opt="ndots:1" \
alpine:3.20 nslookup deb.debian.org
Fix 1.2: Docker Compose dns and dns_opt
services:
web:
image: alpine:3.20
dns:
- 1.1.1.1
- 8.8.8.8
dns_opt:
- ndots:1
- timeout:2
- attempts:3
Compose puts services on its own user-defined network, so /etc/resolv.conf inside the container keeps nameserver 127.0.0.11 for internal service discovery while listing your configured servers under # ExtServers:
![Docker Compose /etc/resolv.conf verification showing nameserver 127.0.0.11, options ndots:1 timeout:2 attempts:3, and # ExtServers: [1.1.1.1 8.8.8.8]](https://i0.wp.com/gearflowlab.com/wp-content/uploads/2026/11/IMG_14_A_rescued_orig4274_compose_dns_opt_resolv_conf_1270011_retina-2.webp?resize=1920%2C1020&ssl=1)
# Generated by Docker Engine.
# This file can be edited; Docker Engine will not make further changes once it
# has been modified.
nameserver 127.0.0.11
options ndots:1 timeout:2 attempts:3
# Based on host file: '/etc/resolv.conf' (internal resolver)
# ExtServers: [1.1.1.1 8.8.8.8]
# Overrides: [nameservers options]
# Option ndots from: override
On a corporate network or VPN: If your firewall blocks public DNS servers (
1.1.1.1,8.8.8.8) or your container needs to resolve internal company hostnames (*.corp.internal), replace1.1.1.1and8.8.8.8with your organization's internal DNS server IPs (which you can find from PowerShell withipconfig.exe /all).
A RUN edit of /etc/resolv.conf is gone at run time
As shown in Case C of our first test run, adding RUN echo "options single-request-reopen" >> /etc/resolv.conf or RUN echo "nameserver 1.1.1.1" > /etc/resolv.conf inside a Dockerfile only affects that single RUN instruction during docker build. When you later start a container from the image, Docker mounts a fresh /etc/resolv.conf into the container and overwrites your changes. Always pass --dns / --dns-opt at run time or set dns: / dns_opt: in docker-compose.yml:
![Live n8n 1.76.1 workflow editor on port 5678 executing an outbound HTTP Request on gfl-dnsnet with Compose dns [1.1.1.1, 8.8.8.8] and dns_opt [ndots:1, timeout:2, attempts:3]](https://i0.wp.com/gearflowlab.com/wp-content/uploads/2026/11/IMG_15_B_n8n_webui_compose_dns_1111_extservers_http_lookup_verified-2.webp?resize=1920%2C1020&ssl=1)
Solution 2: Default DNS servers in /etc/docker/daemon.json (Docker Engine inside a distro)
If you run Docker Engine directly inside a WSL 2 Linux distribution, setting "dns" in /etc/docker/daemon.json configures default resolvers for every container and every docker build step on that daemon whenever per-container --dns flags are not provided. (If you use Docker Desktop, edit the equivalent JSON under Docker Desktop Settings → Docker Engine instead of inside a WSL distro.)
Step 2.1: Edit /etc/docker/daemon.json
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<'EOF'
{
"dns": ["1.1.1.1", "8.8.8.8"],
"dns-opts": ["ndots:1", "timeout:2", "attempts:3"]
}
EOF
Step 2.2: Check the JSON before restarting
A trailing comma or syntax error in /etc/docker/daemon.json prevents dockerd from starting. Validate the file with Python's built-in JSON parser first:
python3 -m json.tool /etc/docker/daemon.json > /dev/null && echo "JSON Valid"
Step 2.3: Restart the Docker daemon
# On WSL distros with systemd enabled:
sudo systemctl restart docker
# On WSL distros using SysVinit / service scripts:
sudo service docker restart

Solution 3: WSL DNS tunneling and mirrored networking (from Microsoft's docs)
When DNS fails inside the WSL 2 distribution itself, most commonly after connecting a corporate VPN or on enterprise Windows 11 machines with strict host firewall policies, Microsoft recommends enabling WSL DNS tunneling (dnsTunneling=true) and, on Windows 11 22H2+ (build 22621+), mirrored mode networking (networkingMode=mirrored). Instead of sending UDP port 53 packets over the Hyper-V NAT virtual switch, DNS tunneling resolves queries directly through the Windows host via virtualization features and sets the distro's /etc/resolv.conf to nameserver 10.255.255.254.
Keep one important boundary from Microsoft's WSL networking documentation in mind: Docker Desktop containers bypass WSL DNS tunneling (they use 192.168.65.7 inside Docker Desktop's environment). Solution 3 therefore fixes DNS for the WSL distro and for Docker Engine running inside a WSL distro, whereas Docker Desktop containers still need Solution 1 if 192.168.65.7 cannot reach an upstream resolver.
Step 3.1: Check your WSL version
wsl.exe --version
wsl.exe --update
Step 3.2: Configure %USERPROFILE%\.wslconfig
.wslconfig Key under [wsl2] |
Default Value | What It Does (from Microsoft's WSL Config Docs) |
|---|---|---|
networkingMode |
NAT |
Set to mirrored on Windows 11 22H2+ to mirror host network interfaces into WSL and improve VPN compatibility. |
dnsTunneling |
true |
Routes WSL DNS requests directly to the Windows host without UDP packets over the NAT virtual switch. |
dnsTunnelingIpAddress |
10.255.255.254 |
Specifies the IP address written as the nameserver in the WSL distro's /etc/resolv.conf when DNS tunneling is active. |
autoProxy |
true |
Enforces Windows HTTP proxy information inside the WSL distribution. |
firewall |
true |
Applies Windows Firewall rules and Hyper-V firewall rules to WSL network traffic. |

If you stay on
networkingMode=NATwithout DNS tunneling: RunGet-NetFirewallProfile -PolicyStore ActiveStorein an elevated PowerShell window and checkAllowLocalFirewallRulesandAllowInboundRules. If either setting isFalse, Windows Group Policy is blocking the host networking service firewall rule that NAT mode needs to relay DNS queries from WSL.
Step 3.3: Restart WSL
After saving %USERPROFILE%\.wslconfig, shut down WSL from PowerShell and wait at least 8 seconds before reopening your Linux terminal so the utility VM restarts cleanly:
wsl.exe --shutdown
Solution 4: Write the distro's /etc/resolv.conf yourself (Microsoft's VPN workaround)
If an older WSL build or a legacy VPN client still prevents automatic DNS resolution inside a WSL distribution, Microsoft's troubleshooting guide documents a manual fallback: stop WSL from auto-generating /etc/resolv.conf and write your Windows host's active DNS servers into the file yourself.
- Step 4.1: Find the DNS servers Windows is currently using: In PowerShell, run
ipconfig.exe /alland copy the IPv4 addresses listed underDNS Serversfor your active VPN or network adapter. - Step 4.2: Tell WSL not to overwrite
/etc/resolv.conf: Inside the WSL distro, setgenerateResolvConf = falsein/etc/wsl.conf:[network] generateResolvConf = false - Step 4.3: Replace the symlink with a regular file: After running
wsl.exe --shutdownfrom PowerShell, remove the old symlink in WSL and write the DNS servers you copied:sudo unlink /etc/resolv.conf sudo tee /etc/resolv.conf <<'EOF' nameserver 1.1.1.1 nameserver 8.8.8.8 EOF - Step 4.4: Watch out for two side effects: Setting
generateResolvConf = falsedisables WSL DNS tunneling for that distribution, and when you disconnect from the VPN or move to another network, you must update/etc/resolv.confmanually (or removegenerateResolvConf = false, delete/etc/resolv.conf, and runwsl.exe --shutdownso WSL manages it again):

Which fix fits your setup
Use the comparison table below to pick the narrowest fix that matches your Docker setup (Official Docker Desktop vs Docker Engine inside a WSL 2 distribution) and network environment:
| Fix | Applies To | Scope | Tested Here? | Watch Out For |
|---|---|---|---|---|
Solution 1: --dns / Compose dns: & dns_opt: |
Docker Desktop & Docker Engine in a WSL distro (including Alpine musl) |
One container or Compose service at run time | Yes (2025-01-26) |
A RUN echo >> /etc/resolv.conf in a Dockerfile is overwritten at container start; docker build has no --dns flag. |
Solution 2: /etc/docker/daemon.json "dns" |
Docker Engine inside a WSL distro (or Docker Desktop Settings → Docker Engine) | All containers & builds on that daemon | Config validated (json.tool) |
Requires sudo systemctl restart docker; public IPs (1.1.1.1) fail if your VPN only allows internal corporate DNS. |
Solution 3: .wslconfig dnsTunneling=true / mirrored |
WSL 2 distributions on Windows 11 22H2+ | All WSL 2 distros on the Windows host | From Microsoft's WSL docs | Docker Desktop containers use 192.168.65.7 and bypass WSL DNS tunneling; pair with Solution 1 for Desktop containers. |
Solution 4: Manual /etc/resolv.conf (generateResolvConf = false) |
A single WSL 2 distribution on legacy VPNs | That WSL distro (and containers copying its file) | From Microsoft's WSL docs | Opting out of auto-generation disables WSL DNS tunneling and must be updated or reverted when switching networks. |

What I didn't test
- Docker Engine installed directly inside a WSL distro, live VPN client intercepts, and Windows Firewall Group Policy blocks: My empirical runs on
2025-01-24through2025-01-26were executed on Official Docker Desktop for Windows 11 (WSL 2 backend, Engine27.3.1) using--dns 192.0.2.1to simulate an unreachable upstream resolver. The behavior of127.0.0.53loopback stripping,/etc/docker/daemon.jsoninside a distro,dnsTunneling=true(10.255.255.254), andgenerateResolvConf = falsecomes directly from Docker's and Microsoft's official documentation. - Hardware firewall packet drops that require
single-requestorsingle-request-reopen: I verified that passing--dns-optwrites the option into/etc/resolv.confat container run time and measured howmuslandglibchandletimeoutandattemptsagainst an unreachable server, but I did not test against a hardware NAT device that drops parallel IPv4Aand IPv6AAAApackets on the same socket. docker buildwith a dead daemon resolver: I ran theapt-get update && apt-get install -y curlexperiments withdocker run --dns ...rather than inside adocker buildstep.

Last reviewed: 2025-01-26. Measured between 2025-01-24 and 2025-01-26 (KST) on Docker Desktop for Windows 11 (WSL 2 backend, Docker Engine 27.3.1, build ce12230, Linux kernel 6.6.87.2-microsoft-standard-WSL2) using alpine:3.19, alpine:3.20, python:3.13-slim, python:3.13-alpine, node:22-alpine, debian:bookworm-slim, and ubuntu:24.04. WSL 2 DNS tunneling (10.255.255.254), .wslconfig settings, and 127.0.0.53 fallback behaviors are referenced from Microsoft's WSL Networking documentation and Docker's Container Networking documentation.
Run Prefilled Sizing Math & Download the 1-Page Runbook
Generate hardened Compose service definitions with explicit healthchecks and verify Thunderbolt dock display bandwidth.