Search code examples
dockerdocker-for-windows

Docker cannot access any Internet URL during build


I have the following Dockerfile:

FROM mcr.microsoft.com/windows/servercore:ltsc2019
SHELL ["powershell", "-Command"]

RUN Invoke-WebRequest -UseBasicParsing http://www.google.com

On my Windows 10 machine, I run docker build . and get the following:

enter image description here

Basically, Docker is unable to access any Internet URL I try. I can run the same Dockerfile on my Windows Server 2019 Core machine and everything works fine. I'm running Docker version 18.09.2 and haven't updated it recently. This was working a few days ago, so it's a new issue. I've tried restarting the Docker engine and also rebooting. I've also tried a docker system prune. Any ideas what broke this? I'd rather not reinstall Docker if possible.

Docker Info:

Client: Docker Engine - Community
 Version:           18.09.2
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        6247962
 Built:             Sun Feb 10 04:12:31 2019
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.2
  API version:      1.39 (minimum version 1.24)
  Go version:       go1.10.6
  Git commit:       6247962
  Built:            Sun Feb 10 04:28:48 2019
  OS/Arch:          windows/amd64
  Experimental:     false

Update: Seems to be DNS related. I can ping things.

enter image description here


Solution

  • This is a known issue with ltsc2019 images (https://github.com/Azure/AKS/issues/1029). Put following at the start of your dockerfile or before entrypoint Set-DnsClientServerAddress -InterfaceIndex (Get-NetAdapter).IfIndex -ServerAddresses ('8.8.8.8')