在我的dockerfile中,有一行RUN PowerShell -ExecutionPolicy Unrestricted -File /approot/bin/DockerScripts/reqs.ps1
在reqs.ps1中,有一个invoke-webrequest命令,例如Invoke-WebRequest -Uri https://path/to/exe/ExeNeeded.exe -OutFile C:\ExeNeeded.exe
在计算机上运行docker build
时,我在RUN PowerShell -ExecutionPolicy Unrestricted -File /approot/bin/DockerScripts/reqs.ps1
步骤上收到错误消息
错误是:
Invoke-WebRequest : The remote name could not be resolved:
https://path/to/exe/ExeNeeded.exe
At C:\approot\bin\DockerScripts\reqs.ps1:5 char:1
+ Invoke-WebRequest -Uri https://path/to/exe/ExeNeeded.exe
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:Htt
pWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShe
ll.Commands.InvokeWebRequestCommand
我能够通过网络浏览器访问https://path/to/exe/ExeNeeded.exe
,所以我知道该网址很好。我还临时关闭了计算机上的防火墙。我不确定为什么Invoke-WebRequest
仍然无法正常工作。
答案 0 :(得分:0)
对于 Windows 用户来说,它是众所周知的 issue#6453。构建图像时添加网络参数。
docker build -t myProject . --network "Default Switch"