How can I set the network option with repo2docker?

Hello,

When I try to use repo2docker, I don’t seem to get further than step 3/56:

Picked Git content provider.
Cloning into '/tmp/ahhesam/repo2docker7mux9rfu'...
remote: Enumerating objects: 8, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 8 (delta 0), reused 6 (delta 0), pack-reused 0
Unpacking objects: 100% (8/8), done.
Using CondaBuildPack builder
Step 1/56 : FROM buildpack-deps:bionic
 ---> 84f9345349b1
Step 2/56 : ENV DEBIAN_FRONTEND=noninteractive
 ---> Using cache
 ---> 5fcc005502c4
Step 3/56 : 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 2819b98fab20
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease  Temporary failure resolving 'security.ubuntu.com'
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 2819b98fab20
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

When I run build the Dockerfile (that I get with the --debug flag) manually, and set --network=host, I don’t get these errors.

Is there a way to tell repo2docker that I want to use the host network?

Cheers,
Ahmad

Currently there is no way to pass specific docker options through the repo2docker CLI.

Could you explain a bit why you need to use the host network in order for processes inside a container to be able to connect to the outside world?

Thanks for your reply. I am not entirely sure why I need the host network, but I suspect it has something to do with the network I am on. My guess is that there are certain network restrictions preventing me from using any other network type for docker containers. I also use the --net=host options to other (already-built) docker containers, without which I wouldn’t have internet access inside docker.

Any suggestions on a quick fix?

Is there a environment variable that docker looks at where we can put config options like this? That would be a quick fix.

Unfortunately there seems to be no such variables.

In the end I was able to change some docker configurations on my local machine (not the remote machine on which I was trying it on initially). My local machine had the same issue (only network=host worked), but I resolved this by doing:

docker-machine create default
docker-machine regenerate-certs default
eval "$(docker-machine env default)"

This generated the TLS certification that I was missing in order to use the default network type.

It would still be nice to be able to pass my own build command line options to docker with r2d, so that I could do this also on machines where this does not solve the issue (like on my remote machine).

Thanks for having a look at my issue @betatim

Cheers,
Ahmad

1 Like