How to install Docker on Windows behind a proxy

My journey into Docker started with TensorFlow, Google's machine learning library. TensorFlow provided no installation instructions for a Windows machine, but they did have instructions for installing it using Docker.

Okay, so I guess I'll install Docker first. Unfortunatly that process ended up taking the better half of my morning. Following are my steps for anyone else attempting to jump through the same hoops.

Installing the Docker toolbox

Head over to the Docker Toolbox page to grab the install. At the time of writing it was roughly 202 MB.

I installed it with all the default settings. Afterwards I ended up with a few shortcuts. Clicking on the Docker Quickstart Terminal launched a window but returned the following error:

Error creating machine: Error in driver during machine creation: This computer doesn't have VT-X/AMD-V enabled. Enabling it in the BIOS is mandatory

Enabling VT-X

Whoops, looks like the first step was checking to see if you have this feature enabled.

Microsoft has a neat little utility you can download that will tell you the same thing... Yup... I don't have hardware virtualization enabled.

How do you enable VT-x or AMD-v? Well, for starters, your CPU needs to have the feature built in. You can check by Googling your processor. For example, I'm using an Intel Core i7-3770 processor, which lists the features here. Specifically this is what I'm looking for

The next thing you need to do is enable it in your BIOS. BIOS is the program that computers launch before the operating system starts up. I restarted my computer and held down the F12 button to get into the BIOS screen. Usually there's a very brief flash of text on your screen before Windows starts up that tells you which button you have to hold to get into the BIOS.

Anyways, once I was there I found the setting and enabled it. I also enabled VT-d in case that offered speed improvements as well.

Now when I double clicked the short cut it created the first virtual machine without any problems. I moved onto the next step by typing docker run hello-world and ran into the next problem:

Error occurred trying to connect

An error occurred trying to connect: Post https://192.168.99.100:2376/v1.21/containers/create: Forbidden

I should mention that I'm running behind a corporate web proxy which causes this problem. It was a little confusing exactly what was going wrong here, but after some trial and error I figured it out.

A Docker machine is the combination of a Docker host and a configured client. In this case, we configured a virtual machine with the Docker client on it. We're now trying to talk to that machine located at 192.168.99.100:2376, but the proxy gets in the way. You may recognize 192.168.XXX.XXX as a private network address, so it's a little strange that our proxy is getting in the way, but nonetheless it is.

We need to a way to avoid using the proxy when talking to our Docker machine.

To get a list of your Docker machines, type docker-machine ls

$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM
default   *        virtualbox   Running   tcp://192.168.99.100:2376

To get the IP address of your default machine you can type docker-machine ip default

Therefore, to set the environemtal variable NO_PROXY to this machine's IP address you'll want to type export NO_PROXY=$(docker-machine ip default)

You can verify that it's set correctly by outputing all the environtal variables with printenv

$ printenv | grep PROXY
NO_PROXY=192.168.99.100
HTTP_PROXY=http://proxy.corp:8080

Now when you run docker run hello-world you should no longer get the error about trying to connect: Post https://192.168.99.100:2376/v1.21/containers/create: Forbidden

For me, I got a different error:

Next, set the proxy on your new Docker machine

If you ran into

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
Pulling repository docker.io/library/hello-world
Error while pulling image: Get https://index.docker.io/v1/repositories/library/hello-world/images: x509: certificate signed by unknown authority

it might mean your Docker machine is unable to connect to the outside world because it isn't setup to use the proxy.

Let's connect to the Docker machine by typing

docker-machine ssh default

Once connected to the Docker machine, get root access by typing

sudo -s

Then configure the proxy:

echo "export HTTP_PROXY=http://username:password@corporate.proxy.com:port" >> /var/lib/boot2docker/profile
echo "export HTTPS_PROXY=http://username:password@corporate.proxy.com:port" >> /var/lib/boot2docker/profile

You can verify that they've been written to the profile file by typing:

cat /var/lib/boot2docker/profile

Then exit out of root by typing exit and then exit out of the SSH session by typing exit again.

Finally restart the Docker machine by typing

docker-machine restart default

Success!

You should now be able to run docker run hello-world

In conclusion, to install Docker on a Windows machine:

  1. First I had to enable Virtualization Technology in my BIOS.
  2. Disable the proxy from interfering when connecting to the Docker machine by setting NO_PROXY equal to my new virtual machine's private IP address.
  3. Then once I could connect to that virtual machine, I set up the HTTP_PROXY and HTTPS_PROXY equal to my corporate proxy address.
  4. After restarting the virtual machine I was able to run the basic hello-world Docker image.

Whew. Now to actually install TensorFlow...

Further reading

If you're looking for more Docker resources, check out these books:

Good luck!