Build issue: apt-get cannot connect to

I’m working through the “Getting Started with Docker” tutorial. I’m working within a corporate network. I followed the troubleshooting hints and edited /var/lib/boot2docker/profile in my default docker machine to configure it for the corporate network proxy. That worked and allowed general access beyond the corporate network.
However, when I reached the “Build your own image” step in the tutorial I the apt-get of is failing during the build saying that it cannot connect. I see that this is an IPv6 address and perhaps that is the issue. I’ve read through the docs I can find on IPv6, but have not been able to figure this out. This seems like it may be a general issue, but I could not find a solution in the forums. If I’ve missed it, please point me in the right direction.

Expected behavior

The build should succeed and apt-get should be able to connect with

Actual behavior

The build fails because apt-get cannot connect to


I’m running this on my laptop running Windows 7.
Docker version: 1.11.2
I verified that I can connect to via FireFox from my laptop.
My guess is that this is related to the fact that this is an IPv6 address and for some reason this is not working.

Steps to reproduce the behavior

See for the context.
Here is the Dockerfile:
FROM docker/whalesay:latest
RUN apt-get -y update && apt-get install -y fortunes
CMD /usr/games/fortunes -a | cowsay

The command run:
$ docker build -t docker-whale .

The first part of the output from the command:
[The Docker forums disallow me from including more than two links, so have to modify the output to not show the URLs as links. So I’ve replaced http:// with LINK/]

Sending build context to Docker daemon 2.048 kB
Step 1 : FROM docker/whalesay:latest
—> 6b362a9f73eb
Step 2 : RUN apt-get -y update && apt-get install -y fortunes
—> Running in 9542e94271ab
Err LINK/ trusty InRelease

Err LINK/ trusty-updates InRelease

Err LINK/ trusty-security InRelease

Err LINK/ trusty Release.gpg
Cannot initiate the connection to (2001:67c:1560:8001::11). - connect (101: Network is unreachable) [IP: 2001:67c:15
60:8001::11 80]
Err LINK/ trusty-updates Release.gpg
Cannot initiate the connection to (2001:67c:1560:8001::11). - connect (101: Network is unreachable) [IP: 2001:67c:15
60:8001::11 80]
Err LINK/ trusty-security Release.gpg
Cannot initiate the connection to (2001:67c:1560:8001::11). - connect (101: Network is unreachable) [IP: 2001:67c:15
60:8001::11 80]
[Many more lines of output with similar errors]

In case it is relevant here are the changes I made to /var/lib/boot2docker/profile with the internal names of the proxy replaced with XXX:
export ""
export ""
export “NO_PROXY=192.168.99.,.local,169.254/16,,192.168.59.

I did some further testing and it does look like a proxy issue and not an IPv6 issue.
I used putty to ssh to the docker VM on my laptop (Boot2Docker version 1.11.2).
I then did a WGET without specifying a proxy and it timed out. I added the proxy and it connected and downloaded successfully from the host in question. Here it is with the internal proxy details X’ed out.

docker@default:~$ wget
Connecting to (
wget: download timed out
docker@default:~$ sudo env wget
Connecting to (ddd.dd.dd.ddd:80)
index.html 100% |***********************************************************************************************************************************| 696 0:00:00 ETA

That would imply to me that the proxy lines I specified in /var/lib/boot2docker/profile are not being used by docker. I’ll do some more digging to see why that might be.

They apply to the Docker daemon’s network connections, like docker pull commands, but they don’t apply to any code that’s running in containers, including docker build steps.

If you’re running a pre-existing container, you could docker run -e http_proxy=... to set a required environment variable. Dockerfiles must specially be set up to support proxies; docker build | Docker Documentation is probably a good starting point.

Thanks to comments from @dmaze I was finally able to get this to work using the following build command:
docker build --build-arg http_proxy= -t docker-whale .

Originally I followed the example in the build CLI reference sited above by @dmaze:
docker build --build-arg HTTP_PROXY= .
It took me quite a while to figure out that apt-get uses http_proxy, and ignores HTTP_PROXY. Once I switched to lower case then it worked.

The Dockerfile reference indicates that an ARG command is predefined for both HTTP_PROXY and http_proxy as well as the other similar environment variables: https_proxy, no_proxy, etc. I tried to figure out how to pass both HTTP_PROXY and http_proxy in the build statement, but no matter what I tried I get the error:
C:\dev\tools\DockerToolbox\docker.exe: “build” requires 1 argument.

I could not find an example or an explanation for how to set multiple --build-arg name=value pairs. If someone could provide a working example of this syntax that would help. I’d like to standardize on a build syntax that handles upper and lower case usage of these networking environment variables.

Thanks for the pointers.

Not sure what I did wrong last night, but I tried again today and was able to specify multiple --build-arg parameters like this:

docker build --build-arg HTTP_PROXY= --build-arg http_proxy= -t docker-whale .

Sorry for the confusion.

I tried this also. But it didn’t work for me.

Error logs:

sudo docker build -t rohit/dockerfile:v2 .
Sending build context to Docker daemon 2.048 kB
Step 1/2 : FROM ubuntu:16.04
—> 0ef2e08ed3fa
Step 2/2 : RUN apt-get update && apt-get upgrade -y && apt-get install -y software-properties-common && add-apt-repository ppa:webupd8team/java -y && apt-get update && echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && apt-get install -y oracle-java8-installer && apt-get clean
—> Running in 914b0b5f239d
Err:1 xenial InRelease
Temporary failure resolving ‘

Any suggestions?