簡體   English   中英

如何在使用Docker時為NuGet配置代理?

[英]How to configure proxy for NuGet while using Docker?

我在構建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。 沒有任何效果。

請讓我知道在docker環境中設置“代理”以使dotnet恢復工作的過程。

謝謝。

在這里查看我的答案。

基本上,您應該通過添加構建參數來指示docker構建環境使用代理:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM