title: docker build in gitlab can't find packages to build
body: <p>I have a local gitlab runner that is behind a proxy. When building docker images, it fails to access the repos.</p>
  <p>Errors:</p>
  <blockquote>
  <p>Err:1 <a href="http://deb.debian.org/debian" rel="nofollow noreferrer">http://deb.debian.org/debian</a> buster InRelease
  Could not connect to deb.debian.org:80 (199.232.98.132). - connect (111: Connection refused)</p>
  </blockquote>
  <p>Relevant part of CI/CD</p>
  <pre class="lang-yaml prettyprint-override"><code>build_image:
    image: docker:20.10.16
    services:
      - docker:20.10.16-dind
    variables:
      HTTPS_PROXY: http://proxy.example.com:3128
      HTTP_PROXY: http://proxy.example.com:3128
      NO_PROXY: docker
    stage: test
    before_script:
      - docker info
      - docker login nexus-docker.example.com:5000 -u $NEXUS_USER -p $NEXUS_PASS
    script:
      - docker build -t nexus-docker.example.com:5000/occ/groupsyncer:latest .
    except:
      - master
  </code></pre>
  <p>gitlab runner config:</p>
  <pre class="lang-ini prettyprint-override"><code>[[runners]]
    name = &quot;docker-runner&quot;
    url = &quot;https://gitlab.example.com/&quot;
    token = &quot;REDACTED&quot;
    executor = &quot;docker&quot;
    cache_dir=&quot;/cache&quot;
    clone_url = &quot;https://gitlab.example.com/&quot;
    environment = [&quot;https_proxy=http://squidproxy.example.com:3128&quot;, &quot;http_proxy=http://squidproxy.example.com:3128&quot;, &quot;HTTPS_PROXY=squidproxy.example.com:3128&quot;, &quot;HTTP_PROXY=squidproxy.example.com:3128&quot;, &quot;no_proxy=gitlab.example.com&quot;, &quot;NO_PROXY=gitlab.example.com,docker,thealias&quot;]
    [runners.custom_build_dir]
    [runners.cache]
      [runners.cache.s3]
      [runners.cache.gcs]
      [runners.cache.azure]
    [runners.docker]
      volumes = [&quot;/var/run/docker.sock:/var/run/docker.sock&quot;,&quot;/opt/gitlab-runner/cache:/cache:rw&quot;]
      tls_verify = false
      image = &quot;docker:20.10.16&quot;
      privileged = true
      disable_entrypoint_overwrite = false
      oom_kill_disable = false
      disable_cache = false
      shm_size = 0
  </code></pre>
  <p>/etc/systemd/system/docker.service.d/http-proxy.conf</p>
  <pre class="lang-ini prettyprint-override"><code>Environment=&quot;HTTP_PROXY=http://squidproxy.example.com:3128&quot; &quot;HTTPS_PROXY=http://squidproxy.example.com:3128&quot; &quot;NO_PROXY=.example.com,.occdev.example.com&quot; &quot;http_proxy=http://squidproxy.example.com:3128&quot; &quot;https_proxy=http://squidproxy.example.com:3128&quot;
  </code></pre>
  <p><em>Domain edited to example.com for posting</em></p>