A Little background on the environment. Corporate environment that works only on Cisco AnyConnect VPN, Has proxy server to be setup to access git or internet, Windows Laptop running Docker CE latest version with linux container.
I am trying out the microservices sample as in https://dotnet.microsoft.com/learn/aspnet/microservice-tutorial/docker-image. Installed few nuget packages to connect to database in same web api. Added a method to display records from database. Works perfectly fine in debug and release mode in kestrel, IIS Express and IIS in Host machine. Created a docker file with below content
# https://hub.docker.com/_/microsoft-dotnet-core
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /source
# copy csproj and restore as distinct layers
COPY *.sln .
COPY *.csproj .
RUN dotnet restore "ms.sln"
# copy everything else and build app
COPY . .
WORKDIR /source
RUN dotnet publish "ms.sln" -c release -o /app --no-restore
# final stage/image
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
COPY --from=build /app ./
ENTRYPOINT ["dotnet", "ms.dll"]
This is the build command that i ran in command prompt.
docker build --build-arg HTTP_PROXY=http://server:port--build-arg HTTPS_PROXY=http://server:port -t microservice .
When it starts doing the dotnet restore.. i get this error which i don't understand. I even setup the proxy in the docker settings.
[build 5/8] RUN dotnet restore "ms.sln":
#12 0.843 Determining projects to restore...
#12 1.487 /usr/share/dotnet/sdk/3.1.402/NuGet.targets(128,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [/source/ms.sln]
#12 1.487 /usr/share/dotnet/sdk/3.1.402/NuGet.targets(128,5): error : NTLM authentication is not possible with default credentials on this platform. [/source/ms.sln]
------
failed to solve with frontend dockerfile.v0: failed to build LLB: executor failed running [/bin/sh -c dotnet restore "ms.sln"]: runc did not terminate sucessfully
Articles that i already read through and tried
http://codebuckets.com/2020/08/01/nuget-restore-failing-in-docker-container/
https://github.com/moby/moby/issues/24697
Windows containers have no internet access, but Linux containers do - with VPN-Client active on host
I had same problem on Win 10 docker desktop. I solved it by setting Settings -> Resources -> Network -> DNS server -> Manual DNS configuration to 8.8.8.8.
Also make sure to use IP address of proxy server instead of DNS name in both HTTPS_PROXY and HTTP_PROXY. Example HTTP_PROXY=http://123.123.123.123:8080
To get the IP address of proxy server, go to chrome://net-export/ in chrome and export the file. In the file, IP is available under PROXY variable, search for the same.