Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 439
Rajat Rokade Avatar asked Apr 12 '19 06:04

Rajat Rokade


1 Answers

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>
like image 164
ltuska Avatar answered Oct 29 '22 12:10

ltuska