Docker在构建期间无法访问任何Internet URL

时间:2019-06-26 18:24:23

标签: docker docker-windows

我有以下Dockerfile:

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

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

在Windows 10计算机上,我运行docker build .并获得以下信息:

enter image description here

基本上,Docker无法访问我尝试的任何Internet URL。我可以在Windows Server 2019 Core计算机上运行相同的Dockerfile,并且一切正常。我正在运行Docker版本18.09.2,并且最近没有对其进行更新。这是几天前的工作,所以是新问题。我试过重启Docker引擎,然后重启。我也尝试过docker system prune。有什么想法打破了这个吗?如果可能的话,我宁愿不重新安装Docker。

Docker信息:

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

更新:似乎与DNS相关。我可以ping通。

enter image description here

1 个答案:

答案 0 :(得分:1)

这是ltsc2019图像(https://github.com/Azure/AKS/issues/1029)的一个已知问题。将以下内容放在dockerfile的开头或入口点之前 Set-DnsClientServerAddress -InterfaceIndex (Get-NetAdapter).IfIndex -ServerAddresses ('8.8.8.8')