If I create a new console application using dotnet classlib -lang f# -o hello-docker
, cd
into the directory and then run dotnet restore
, everything works as expected.
However, if I add a Dockerfile
with the following content
FROM microsoft/dotnet:2-sdk
WORKDIR /hello
COPY hello-docker.fsproj .
COPY *.fs ./
RUN dotnet restore
RUN dotnet build
ENTRYPOINT [ "dotnet", "run" ]
and run docker build .
, it fails to reach nuget.org
with the following message:
/usr/share/dotnet/sdk/2.0.0/NuGet.targets(102,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [/hello/hello-docker.fsproj]
/usr/share/dotnet/sdk/2.0.0/NuGet.targets(102,5): error : An error occurred while sending the request. [/hello/hello-docker.fsproj]
/usr/share/dotnet/sdk/2.0.0/NuGet.targets(102,5): error : Couldn't resolve host name [/hello/hello-docker.fsproj]
The command '/bin/sh -c dotnet restore' returned a non-zero code: 1
Why can I restore locally, but not inside the Docker container?
I fixed it by going into properties/sharing on my network adapter and shared it with the hyper-v/docker switch...think it was called nat or something.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With