0

I'm using windows containers in windows 10. I've set proxy variables(HTTP_PROXY,HTTPS_PROXY) in environmental variable setup and using VPN. I also configured resources -> Proxies.

I was trying to build docker image with following Dockerfile content.

FROM mcr.microsoft.com/windows/servercore:ltsc2019
SHELL ["cmd", "/S", "/C"]

RUN mkdir c:\temp \
    && curl -SL --output c:\temp\vs_buildtools.exe https://aka.ms/vs/16/release/vs_buildtools.exe

When this docker image build command is executed it shows following error.

Step 5/5 : RUN mkdir c:\temp     && curl -SL --output c:\temp\vs_buildtools.exe https://aka.ms/vs/16/release/vs_buildtools.exe
 ---> Running in 0c134b2d004a
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:12 --:--:--     0curl: (6) Could not resolve host: aka.ms
The command 'cmd /S /C mkdir c:\temp     && curl -SL --output c:\temp\vs_buildtools.exe https://aka.ms/vs/16/release/vs_buildtools.exe' returned a non-zero code: 6

I tried to build this with build arguments, and added dns: 8.8.8.8 in docker deamon config file

docker build --build-arg HTTP_PROXY --build-arg HTTPS_PROXY --tag=tswin .

But above mentioned error is not solved.

When the same curl command is executed in Windows's CMD it is not throwing any error

C:\Users\mshanm6x>curl -SL --output c:\temp\vs_buildtools.exe https://aka.ms/vs/16/release/vs_buildtools.exe
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100 1432k  100 1432k    0     0   238k      0  0:00:06  0:00:06 --:--:--  332k

Also the same Dockerfile was able to built by without HTTP_PROXY, HTTPS_PROXY env variables and VPN off.

What is the real issue. Why it is not working inside of container with proxy configuration.

1 Answer 1

0

I had the same problem and I found that you have to specify the proxy address also in the curl command.

So your Dockerfile become

FROM mcr.microsoft.com/windows/servercore:ltsc2019

ENV HTTP_PROXY=$HTTP_PROXY
ENV HTTPS_PROXY=$HTTPS_PROXY

SHELL ["cmd", "/S", "/C"]

RUN mkdir c:\temp \
    && curl -SL --output c:\temp\vs_buildtools.exe https://aka.ms/vs/16/release/vs_buildtools.exe --proxy %HTTP_PROXY%

and you will have to call the build command with this instruction

docker build --build-arg HTTP_PROXY --build-arg HTTPS_PROXY --tag=tswin .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.