title: Docker build error: "could not connect to server" (behind proxy)
body: <p><strong>Context:</strong>
  OS:  Windows 10 Pro; Docker ver: 18.09.0 (build 4d60db4); Behind corporate proxy, using CNTLM to solve <a href="https://stackoverflow.com/questions/53475168/docker-for-windows-server-misbehaving-when-trying-to-pull/53494587">this issue</a>. (currently pulling / running image works fine)</p>
  
  <p><strong>Problem:</strong> 
  I was trying to build the following Dockerfile:</p>
  
  <pre><code>FROM alpine:3.5
  RUN apk add --update \
      python3
  RUN pip3 install bottle
  EXPOSE 8000
  COPY main.py /main.py
  CMD python3 /main.py
  </code></pre>
  
  <p>This is what I got:</p>
  
  <pre><code>Sending build context to Docker daemon  11.26kB
  Step 1/6 : FROM alpine:3.5
   ---&gt; dc496f71dbb5
  Step 2/6 : RUN apk add --update     python3
   ---&gt; Running in 7f5099b20192
  fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
  ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.5/main: could not connect to server (check repositories file)
  WARNING: Ignoring APKINDEX.c51f8f92.tar.gz: No such file or directory
  fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community/x86_64/APKINDEX.tar.gz
  ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.5/community: could not connect to server (check repositories file)
  WARNING: Ignoring APKINDEX.d09172fd.tar.gz: No such file or directory
  ERROR: unsatisfiable constraints:
    python3 (missing):
      required by: world[python3]
  The command '/bin/sh -c apk add --update     python3' returned a non-zero code: 1
  </code></pre>
  
  <p>I was able to access the URL from a browser, so there is no problem with the server itself.</p>
  
  <p>I suspected that it has something to do with the proxy not being propagated to the container, as explained in <a href="https://stackoverflow.com/questions/48272933/docker-at-windows-10-proxy-propagation-to-containers-not-working">this question</a>, since I also did not get the http_proxy line when running <code>docker run alpine env</code>. However, after entering the proxies into the config file, it finally appeared. Yet the problem still exists. </p>
  
  <p>I also tried to change the DNS as instructed <a href="https://stackoverflow.com/a/53252555/5122657">here</a>, but the problem is still unsolved.</p>