【问题标题】:dotnet restore error on linux container in docker corporate environment in vpnvpn中docker企业环境中linux容器上的dotnet恢复错误
【发布时间】:2021-01-23 01:22:49
【问题描述】:

关于环境的一点背景。 仅适用于 Cisco AnyConnect VPN 的企业环境,具有要设置的代理服务器以访问 git 或互联网,运行 Docker CE 最新版本和 linux 容器的 Windows 笔记本电脑。

我正在尝试https://dotnet.microsoft.com/learn/aspnet/microservice-tutorial/docker-image 中的微服务示例。 安装了几个 nuget 包以连接到同一 Web api 中的数据库。添加了一种显示数据库记录的方法。在主机中的 kestrel、IIS Express 和 IIS 的调试和发布模式下工作得非常好。 创建了一个包含以下内容的 docker 文件

# 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"]

这是我在命令提示符下运行的构建命令。

docker build --build-arg HTTP_PROXY=http://server:port--build-arg HTTPS_PROXY=http://server:port -t microservice .

当它开始执行 dotnet restore 时.. 我收到了这个我不明白的错误。我什至在 docker 设置中设置了代理。

[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  

我已经阅读并尝试过的文章

NuGet behind a proxy

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

【问题讨论】:

  • 您是否尝试过以小写和大写形式传递代理设置?例如docker build --build-arg HTTP_PROXY=http://server:port --build-arg HTTPS_PROXY=http://server:port --build-arg http_proxy=http://server:port --build-arg https_proxy=http://server:port -t microservice .
  • 我现在试试@SimplyGed
  • 同样的错误@SimplyGed

标签: windows docker .net-core docker-desktop linux-containers


【解决方案1】:

我在 Win 10 docker 桌面上遇到了同样的问题。 我通过将 Settings -> Resources -> Network -> DNS server -> Manual DNS configuration 设置为 8.8.8.8 解决了这个问题。

还要确保在 HTTPS_PROXY 和 HTTP_PROXY 中使用代理服务器的 IP 地址而不是 DNS 名称。示例 HTTP_PROXY=http://123.123.123.123:8080

要获取代理服务器的IP地址,请在chrome中转到chrome://net-export/并导出文件。在文件中,IP在PROXY变量下可用,搜索相同。

【讨论】:

    猜你喜欢
    • 2012-03-30
    • 1970-01-01
    • 2011-12-21
    • 1970-01-01
    • 2011-06-02
    • 1970-01-01
    • 1970-01-01
    • 2013-09-11
    • 2021-02-15
    相关资源
    最近更新 更多