简体   繁体   中英

How to configure proxy for NuGet while using Docker?

I am using dotnet:2.1-sdk as a package while building docker image. The RUN dotnet restore command is failing with below errors:

**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**

Its an issue with proxy because if I bypass the corporate network and connect to my personal network, it works.

I also tried placing the NuGet.Config file the source directory and also tried to copy it to WORKDIR. Nothing worked.

Please let me know the procedure of setting the "Proxy" for making dotnet restore work in the docker environment.

Thanks.

Check my answer here .

Basically, you should instruct the docker build environment to use the proxy by adding build arguments like:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM