Trying to resolve DNS names in docker windows (windows containers) appears broken by default and with no easy way to resolve. There are dozens of posts about this, but few with fixes (and none of those have enough details or actually work).
-
To reproduce
- install docker windows desktop
- switch to windows container mode
-
inside container, rundocker run -it mcr.microsoft.com/windows/servercore:ltsc2022 powershell
and it fails to resolve the nameping www.google.com
- Then repeat above, adding –dns 8.8.8.8 to docker run line and it all works
-
So issue is just the default DNS stuff not working with docker. You CAN workaround some issues by just specifying --dns on the command line. But not all (like docker build scripts) or scripts that indirectly use docker.
- TRIED setting the DNS entry
(see dockerd | Docker Documentation)
{
"dns": [
"8.8.8.8"
],
"builder": {
"gc": {
"defaultKeepStorage": "20GB",
"enabled": true
}
},
"experimental": false,
"features": {
"buildkit": true
}
}
But sadly this doesnt seem to work (appears totally ignored).