我正在尝试运行.NET Core dockerfile,但是在dotnet restore方面一直出现错误。我在Linux容器中运行它。我尝试在Windows容器中运行它,但是在COPY命令期间出现错误。
我有一个docker compose文件,可从子文件夹加载.NET Core dockerfile。我在Powershell中运行“ docker-compose up”。构建过程进入dotnet恢复步骤并抛出此错误:
/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]
我尝试根据以下Stackoverflow帖子:https://stackoverflow.com/a/47837720/2026659
在Visual Studio中更新devenv.exe.config文件。更新devenv.exe.config后,我得到了这个略有不同的错误(还包括整个构建输出):
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
更新:我的某些NuGet软件包托管在我通过VPN访问的本地网络上的私有服务器上。我使用Windows Active Directory登录到我的工作笔记本电脑,并且我认为这些凭据用于访问私有服务器。
更新2:我将登录凭据添加到我的NuGet.config中,如下所示:
...
<packageSourceCredentials>
<api-library>
<add key="Username" value="username" />
<add key="ClearTextPassword" value="password" />
</api-library>
</packageSourceCredentials>
</configuration>
现在在Docker容器中运行dotnet restore时出现另一个错误:
/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).
经过更多的谷歌搜索之后,我认为我需要以其他方式传递登录凭据,可能需要使用个人访问令牌,例如GitHub帖子:https://github.com/microsoft/artifacts-credprovider/issues/63
我不确定该怎么做。
答案 0 :(得分:0)
我能够使用Windows容器解决此问题。