【问题标题】:How to configure proxy for NuGet while using Docker?使用 Docker 时如何为 NuGet 配置代理?
【发布时间】:2019-04-12 06:20:44
【问题描述】:

我在构建 docker 映像时使用 dotnet:2.1-sdk 作为包。 RUN dotnet restore 命令失败并出现以下错误:

**error : Unable to load the service index for source https://api.nuget.org/v3/index.json.**

**error :   A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond**

**The command 'cmd /S /C dotnet restore' returned a non-zero code: 1**

这是代理的问题,因为如果我绕过公司网络并连接到我的个人网络,它就可以工作。

我还尝试将 NuGet.Config 文件放置在源目录中,并尝试将其复制到 WORKDIR。没有任何效果。

请告诉我设置“代理”以使 dotnet restore 在 docker 环境中工作的过程。

谢谢。

【问题讨论】:

    标签: c# docker .net-core nuget dockerfile


    【解决方案1】:

    查看我的答案here

    基本上,您应该通过添加如下构建参数来指示 docker 构建环境使用代理:

    docker build --build-arg HTTP_PROXY=<proxy URL> --build-arg HTTPS_PROXY=<proxy URL> -t <application name>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-29
      • 1970-01-01
      • 2022-01-07
      • 2018-07-01
      • 2021-11-09
      • 1970-01-01
      相关资源
      最近更新 更多