Using repo2docker behind proxy

I’m trying to run repo2docker behind a corporate proxy but it fails while trying to run apt-get when building the docker image with the following errors:

Using PythonBuildPack builder
Step 1/48 : FROM buildpack-deps:bionic
 ---> 62eb152e890f
Step 2/48 : ENV DEBIAN_FRONTEND=noninteractive
 ---> Using cache
 ---> c65e21e2fae9
Step 3/48 : RUN apt-get -qq update &&     apt-get -qq install --yes --no-install-recommends locales > /dev/null &&     apt-get -qq purge &&     apt-get -qq clean &&     rm -rf /var/lib/apt/lists/*
 ---> Running in 1458724cd0dd
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease  Could not connect to archive.ubuntu.com:80 (91.189.88.162), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.149), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.91.23), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.161), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed out
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease  Unable to connect to archive.ubuntu.com:http:
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease  Unable to connect to archive.ubuntu.com:http:
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease  Could not connect to security.ubuntu.com:80 (91.189.88.149), connection timed out Could not connect to security.ubuntu.com:80 (91.189.88.161), connection timed out Could not connect to security.ubuntu.com:80 (91.189.88.162), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.23), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.26), connection timed out Could not connect to security.ubuntu.com:80 (91.189.88.152), connection timed out
W: Some index files failed to download. They have been ignored, or old ones used instead.
E: Package 'locales' has no installation candidate
Removing intermediate container 1458724cd0dd
The command '/bin/sh -c apt-get -qq update &&     apt-get -qq install --yes --no-install-recommends locales > /dev/null &&     apt-get -qq purge &&     apt-get -qq clean &&     rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100The command '/bin/sh -c apt-get -qq update &&     apt-get -qq install --yes --no-install-recommends locales > /dev/null &&     apt-get -qq purge &&     apt-get -qq clean &&     rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100
Traceback (most recent call last):
  File "/home/vagrant/miniconda/lib/python3.7/site-packages/repo2docker/__main__.py", line 340, in main
    r2d.start()
  File "/home/vagrant/miniconda/lib/python3.7/site-packages/repo2docker/app.py", line 687, in start
    self.build()
  File "/home/vagrant/miniconda/lib/python3.7/site-packages/repo2docker/app.py", line 673, in build
    raise docker.errors.BuildError(l['error'], build_log='')
docker.errors.BuildError: The command '/bin/sh -c apt-get -qq update &&     apt-get -qq install --yes --no-install-recommends locales > /dev/null &&     apt-get -qq purge &&     apt-get -qq clean &&     rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100[vagrant@ol7-docker-engine oracle]$ Connection to 127.0.0.1 closed by remote host.
Connection to 127.0.0.1 closed.

Docker works fine by itself so I think the problem is that I need to pass build args to the image. How would I do that?

It looks like your corporate firewall blocks access to http://security.ubuntu.com (and other hosts from which packages would be installed?).

Just to confirm: if you run docker build for a Dockerfile like:

FROM buildpack-deps:bionic
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get -qq update &&     apt-get -qq install --yes --no-install-recommends locales > /dev/null &&     apt-get -qq purge &&     apt-get -qq clean &&     rm -rf /var/lib/apt/lists/*

installing the package succeeds?

What kind of build arguments would you pass in and what exactly do you mean with “build args”? Right now you can’t pass any arguments that you would normally pass to docker build ....

Sorry I should have been more specific. By “build args” I mean the --build-arg flag to docker build.

So

`docker build -t test_image .` 

fails but

`docker build -t test_image --build-arg http_proxy=$http_proxy .` 

works.

Thanks for clarifying!

There is an issue about this: https://github.com/jupyter/repo2docker/issues/645 but as far as I know no one has worked on this. The fact that there is at least one other person looking for this means it would be a good thing to open a Pull Request for if you want to add it.