Docker with dotnet restore causes error: GSSAPI operation failed – An unsupported mechanism was requested

Having a ASP.NET Core 2.2 web application, I try to restore NuGet packages behind a coperate proxy

FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS sdk-image
WORKDIR /app/
ARG HTTP_PROXY
ENV HTTP_PROXY ${HTTP_PROXY}
ENV HTTPS_PROXY ${HTTP_PROXY}
COPY MyProject.csproj .

RUN dotnet restore

with the following docker-compose.yml:

version: '2'
services:
  tool:
    build:
      context: .
      args:
        http_proxy: ${HTTP_PROXY}
networks:
  default:
    ipam:
      driver: default
      config:
        - subnet: 192.168.239.0/21

The network got overriden because Dockers default network conflicts with internal company ranges. HTTP_PROXY is set on the host to a full url like http://user:[email protected]:81.

When running docker-compose up --build it fails on restore:

Step 7/15 : RUN dotnet restore
 ---> Running in 62c8bb6f2f72
/usr/share/dotnet/sdk/2.2.402/NuGet.targets(123,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [/app/MyProject.csproj]
/usr/share/dotnet/sdk/2.2.402/NuGet.targets(123,5): error :   GSSAPI operation failed with error - An unsupported mechanism was requested (Unknown error). [/app/MyProject.csproj]
ERROR: Service 'tool' failed to build: The command '/bin/sh -c dotnet restore' returned a non-zero code: 1

I could not find much information about this issue. A Github issue got this through their local TFS. But I don’t have any self hosted repository, just the corporate proxy between me and NuGets server.

Source: StackOverflow