Solvediotedge Unable to load the service index for source https://api.nuget.org/v3/index.json

Environment: Dev machine running supported version of Windows 10 IoT Enterprise, latest Docker CE switched to Windows containers, Visual Studio COde and IoT Edge plugin. IoT Edge is tested and running. There was known issue with DNS solved by adding fix DNS on OS level.

If we try to build custom C# module based using microsoft/dotnet:2.1-sdk base container we get this error

docker build --rm -f
"c:\Users\stepanb\Documents\IoT Edge Dome\EdgeSolution101\modules\SampleModule101\Dockerfile.windows-amd64" -t stepanb.azurecr.io/samplemodule101:0.0.1-amd64 "c:\Users\stepanb\Documents\IoT Edge Dome\EdgeSolution101\modules\SampleModule101"
Sending build context to Docker daemon 17.41kB
Step 1/10 : FROM microsoft/dotnet:2.1-sdk AS build-env
2.1-sdk: Pulling from microsoft/dotnet
d0c6a1b3dba2: Pull complete
5da99380d93e: Pull complete
23add0d71b40: Pull complete
10c60d2f3305: Pull complete
467e8374427a: Pull complete
4df65c6b837f: Pull complete
eed65dfedd9a: Pull complete
Digest: sha256:3613ad07fc7c9abeb24fccef21de7b8a2d32efbd7299e4b91a5765bc48e3cda5
Status: Downloaded newer image for microsoft/dotnet:2.1-sdk
---> 3b323b0465ee
Step 2/10 : WORKDIR /app
---> Running in 3b098be2d38b
Removing intermediate container 3b098be2d38b
---> 9f6f6daf374f
Step 3/10 : COPY *.csproj ./
---> 9d9d8d3304dc
Step 4/10 : RUN dotnet restore
---> Running in 07145db12328
C:\Program Files\dotnet\sdk\2.1.802\NuGet.targets(123,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\app\SampleModule101.csproj]
C:\Program Files\dotnet\sdk\2.1.802\NuGet.targets(123,5): error : No such host is known [C:\app\SampleModule101.csproj]
The command 'cmd /S /C dotnet restore' returned a non-zero code: 1

If we switch on same computer to Linux containers it works.

33 Answers

✔️Accepted Answer

I really would like this fixed. Just to help anybody else that came across this issue, here's what I did:

There's a file at the path C:\ProgramData\Docker\config\daemon.json. Add the line: "dns": ["8.8.8.8"] in the JSON object.

Ideally, replace it with your actual DNS server. 8.8.8.8 is just a well known DNS server, so it should work.

After adding that line, restart the Docker daemon. You can use the context menu from the system tray for that.

I hope this helps somebody.

Other Answers:

I really would like this fixed. Just to help anybody else that came across this issue, here's what I did:
There's a file at the path C:\ProgramData\Docker\config\daemon.json. Add the line: "dns": ["8.8.8.8"] in the JSON object.
Ideally, replace it with your actual DNS server. 8.8.8.8 is just a well known DNS server, so it should work.
After adding that line, restart the Docker daemon. You can use the context menu from the system tray for that.
I hope this helps somebody.

This solved the issue I had. Thanks @Type1JGB :)

This worked for me too