title: Setting proxy in docker container
body: <p>I'm trying to create Docker container where I need to use apt-get install command. Currently it looks like this:</p>
  
  <pre><code>FROM ubuntu:18.04
  RUN apt-get update &amp;&amp; apt-get install -y \
          build-essential \
          cmake
  </code></pre>
  
  <p>Unfortunately, when I try to build it I'm getting some errors regarding proxy. I am working behind corporate proxy and I'd like my container to work well in such conditions.</p>
  
  <p>I did some reading online and I tired few options:</p>
  
  <p><strong>Option 1</strong></p>
  
  <pre><code>FROM ubuntu:18.04
  ENV http_proxy &lt;HTTP_PROXY&gt;
  ENV https_proxy &lt;HTTPS_PROXY&gt;
  RUN apt-get update &amp;&amp; apt-get upgrade
  </code></pre>
  
  <p><a href="https://stackoverflow.com/a/22184601">https://stackoverflow.com/a/22184601</a></p>
  
  <p><strong>Option 2</strong></p>
  
  <pre><code>FROM ubuntu:18.04
  ENV http_proxy 'http://corporate_proxy:port'
  ENV https_proxy 'http://corporate_proxy:port'
  </code></pre>
  
  <p><a href="https://stackoverflow.com/a/30252882">https://stackoverflow.com/a/30252882</a></p>
  
  <p><strong>Option 3</strong></p>
  
  <pre><code>docker build --build-arg http_proxy=$http_proxy 
  --build-arg https_proxy=$https_proxy -t mytest_docker .
  </code></pre>
  
  <p>Based on <a href="https://elegantinfrastructure.com/docker/ultimate-guide-to-docker-http-proxy-configuration/" rel="nofollow noreferrer">https://elegantinfrastructure.com/docker/ultimate-guide-to-docker-http-proxy-configuration/</a></p>
  
  <p>However, none of this options is working and I'm getting always same error:</p>
  
  <pre><code>Err:1 http://archive.ubuntu.com/ubuntu bionic InRelease
    Temporary failure resolving 'corporate_proxy'
  Err:2 http://security.ubuntu.com/ubuntu bionic-security InRelease
    Temporary failure resolving 'corporate_proxy'
  Err:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
    Temporary failure resolving 'corporate_proxy'
  Err:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
    Temporary failure resolving 'corporate_proxy'
  Reading package lists...
  W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease  Temporary failure resolving 'corporate_proxy'
  </code></pre>
  
  <p><em>corporate_proxy</em> is just a placeholder for actual (working) proxy.</p>
  
  <p>I am sure that the proxy address is correct and is working on host system because I can normally download everything. The problem is only with this docker image.</p>
  
  <p>Any suggestion how I can resolve that?</p>
  
  <hr>
  
  <p><strong>EDIT #1</strong></p>
  
  <p>Based on the answer from @Raoslaw Szamszur I did a bit more debugging. Unfortunately results are still the same.</p>
  
  <p>I have added values to config.json file and restarted daemon. Next I tried one more time doing all of my options with same outcome.</p>
  
  <p>Also I wanted to run just Ubuntu docker using following line:</p>
  
  <pre><code>docker run --name ubunut -it -p &lt;port_http&gt;:&lt;port_http&gt; -p &lt;port_https&gt;:&lt;port_https&gt; ubuntu:18.04
  </code></pre>
  
  <p>Once it was running apt-get is unable to download anything printing same kind of error as previously.</p>
  
  <p>Also this is how this container looked in list</p>
  
  <pre><code>docker container ls --all
  CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                          NAMES
  e6fdeaec3ad9        ubuntu:18.04        "/bin/bash"         3 minutes ago       Up 3 minutes        0.0.0.0:&lt;http_port&gt;-&lt;https_port&gt;-&gt;&lt;http_port&gt;-&lt;https_port&gt;/tcp   ubunut
  </code></pre>