I was writing a blog for the company website today on deploying your .NET applications into Azure Kubernetes Service, I was using Windows images seen as it was .NET and came across a few issues while building the image.
While executing the Dockerfile from the docker build command, the restore step of the Dot Net SDK was taking a while to run, certainly longer than it should for a simple sample application.
After a short time, the command exited out with a network communication error, you can see the exiting error below.
The error returned was:
C:\Program Files\dotnet\sdk\3.1.301\NuGet.targets(128,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\src\HelloWorld.csproj] C:\Program Files\dotnet\sdk\3.1.301\NuGet.targets(128,5): error : No such host is known. [C:\src\HelloWorld.csproj]
I added in a command to by Dockerfile to run a ping against google.com just to see if we had any network connectivity and this failed with unknown host.
I then looked at the configuration settings in the Docker Desktop GUI and found that from more testing no network based operations were working.
With that I added the code below into the Docker Engine settings and restarted the environment.
"dns": [ "220.127.116.11" ]
After the restart, the build then completed as required and everything is now working as expected.