<p>I had the same problem and I found that you have to specify the proxy address also in the curl command.</p>
<p>So your Dockerfile become</p>
<pre><code>FROM mcr.microsoft.com/windows/servercore:ltsc2019

ENV HTTP_PROXY=$HTTP_PROXY
ENV HTTPS_PROXY=$HTTPS_PROXY

SHELL [&quot;cmd&quot;, &quot;/S&quot;, &quot;/C&quot;]

RUN mkdir c:\temp \
    &amp;&amp; curl -SL --output c:\temp\vs_buildtools.exe https://aka.ms/vs/16/release/vs_buildtools.exe --proxy %HTTP_PROXY%
</code></pre>
<p>and you will have to call the build command with this instruction</p>
<pre><code>docker build --build-arg HTTP_PROXY --build-arg HTTPS_PROXY --tag=tswin .
</code></pre>

CC BY-SA 4.0
2022-02-03T07:23:07.380Z
2022-02-03T07:23:07.380Z
nocino87
<p>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 -&gt; Proxies.</p>
<p>I was trying to build docker image with following Dockerfile content.</p>
<pre><code>FROM mcr.microsoft.com/windows/servercore:ltsc2019
SHELL [&quot;cmd&quot;, &quot;/S&quot;, &quot;/C&quot;]

RUN mkdir c:\temp \
    &amp;&amp; curl -SL --output c:\temp\vs_buildtools.exe https://aka.ms/vs/16/release/vs_buildtools.exe
</code></pre>
<p>When this docker image build command is executed it shows following error.</p>
<pre><code>Step 5/5 : RUN mkdir c:\temp     &amp;&amp; curl -SL --output c:\temp\vs_buildtools.exe https://aka.ms/vs/16/release/vs_buildtools.exe
 ---&gt; 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     &amp;&amp; curl -SL --output c:\temp\vs_buildtools.exe https://aka.ms/vs/16/release/vs_buildtools.exe' returned a non-zero code: 6
</code></pre>
<p>I tried to build this with build arguments, and added dns: 8.8.8.8 in docker deamon config file</p>
<pre><code>docker build --build-arg HTTP_PROXY --build-arg HTTPS_PROXY --tag=tswin .
</code></pre>
<p>But above mentioned error is not solved.</p>
<p>When the same curl command is executed in Windows's CMD it is not throwing any error</p>
<pre><code>C:\Users\mshanm6x&gt;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
</code></pre>
<p>Also the same Dockerfile was able to built by without HTTP_PROXY, HTTPS_PROXY env variables and VPN off.</p>
<p>What is the real issue. Why it is not working inside of container with proxy configuration.</p>

<docker><dockerfile>
PROXY is not working inside windows container
imaheshwaran s
# PROXY is not working inside windows container

(Asked by: username_0 on 2021-08-19)

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.

**Tags:** docker, dockerfile


---

## 1 answers

### Answer by username_1 on 2022-02-03. Score: 1

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 .


---

