I'm trying to run a .NET Core dockerfile but keep getting errors with dotnet restore. I'm running it in a Linux container. I tried running it in a Windows container but got an error during the COPY command.
I have a docker compose file that loads a .NET Core dockerfile from a subfolder. I run 'docker-compose up' in Powershell. The build process gets to the dotnet restore step and throws this error:
/usr/share/dotnet/sdk/3.1.100/NuGet.targets(123,5): error : Unable to load the service index for source http://192.168.30.2:8080/tfs/DefaultCollection/_packaging/api-library/nuget/v3/index.json. [/Portal.API/Portal.Api.csproj]
/usr/share/dotnet/sdk/3.1.100/NuGet.targets(123,5): error : GSSAPI operation failed with error - Unspecified GSS failure. Minor code may provide more information (SPNEGO cannot find mechanisms to negotiate). [/Portal.API/Portal.Api.csproj]
I tried updating the devenv.exe.config file in Visual Studio based on this Stackoverflow post: https://stackoverflow.com/a/47837720/2026659
After updating devenv.exe.config I got this slightly different error (also included the entire build output):
Step 1/9 : FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS api-env
---> cef7866e800b
Step 2/9 : WORKDIR /Portal.API
---> Using cache
---> 80eea76dc2a0
Step 3/9 : COPY ./Portal.API/Portal.Api.csproj .
---> Using cache
---> 0739924c5ebf
Step 4/9 : COPY ./Portal.API/NuGet.config .
---> f1a514456db0
Step 5/9 : RUN dotnet restore
---> Running in 9d4a8f5d6239
Restore completed in 8.15 sec for /Portal.API/Portal.Api.csproj.
/usr/share/dotnet/sdk/3.1.100/NuGet.targets(123,5): error : Unable to load the service index for source http://192.168.30.2:8080/tfs/DefaultCollection/_packaging/api-library/nuget/v3/index.json. [/Portal.API/Portal.Api.csproj]
/usr/share/dotnet/sdk/3.1.100/NuGet.targets(123,5): error : Connection refused [/Portal.API/Portal.Api.csproj]
ERROR: Service 'portal.api' failed to build: The command '/bin/sh -c dotnet restore' returned a non-zero code: 1
UPDATE: Some of my NuGet packages are hosted on a private server on a local network which I access via a VPN. I use Windows Active Directory to log in to my work laptop and I think those credentials are used to access the private server.
UPDATE 2: I added login credentials to my NuGet.config like this:
...
<packageSourceCredentials>
<api-library>
<add key="Username" value="username" />
<add key="ClearTextPassword" value="password" />
</api-library>
</packageSourceCredentials>
</configuration>
Now I get a different error when running dotnet restore in the docker container:
/usr/share/dotnet/sdk/3.1.100/NuGet.targets(123,5): error : Unable to load the service index for source http://192.168.30.2:8080/tfs/DefaultCollection/_packaging/api-library/nuget/v3/index.json. [/Portal.API/Portal.Api.csproj]
/usr/share/dotnet/sdk/3.1.100/NuGet.targets(123,5): error : GSSAPI operation failed with error - An invalid name was supplied (Configuration file does not specify default realm).
After doing more googling, I think I need to pass login credentials in a different way, possibly with a Personal Access Token like in this GitHub post: https://github.com/microsoft/artifacts-credprovider/issues/63
I'm not sure how to go about it.