Installing Docker Toolbox On Windows
JeanFrancoisPuget 2700028FGP Visits (40731)
Docker is a great solution to the portability of software. It alleviates the "it worked on my machine, don't understand why it does not run on yours" nightmare. It does so via packaging your software and its execution environment in self contained containers This is an elegant solution to a very general problem. A good Docker introduction is available as online tutorials at htt
Docker is great but it is not easy to use on Windows. Indeed, Docker containers are built on Linux. As a result, Docker needs a Linux machine to run. For Windows, the way to use Docker so far was to install a specific Linux VM called Boot2Docker, then log into that VM and proceed with Docker. It meant you had to know Linux to use Docker, even if you were using a Windows machine.
A Windows friendly Docker client has been announced recently. It can be used with Windows terminals such as Windows command prompt, and Windows Powershell. This client can be installed as part of Docker Toolbox. I only have used it for few days, but there are few things worth sharing with readers. These may save you time if you decide to use Docker Toolbox on Windows.
What follows is based on the version 1.8.3 of Docker Toolbox. Details may change with newer versions as Docker Toolbox is in beta at the time of writing.
Enough theory, let's get started on Windows.
The first step is to download the installer from http
I clicked yes, but things did not went as expected. First, the migration took a long time, then it failed.
Then, after installation, I could not run the default VM as indicate by host is not running:
I later discovered that my Boot2Docker VM had no space left. Maybe that was the cause of the issue. I therefore decided to retry, rebooted my windows machine, and ran the installer again. Indeed, the Docker Toolbox installer overrides existing installation. Upgrading to a more recent Docker Toolbox version only requires running the newer installer.
This time things went fine. I was not offered to migrate my existing Boot2Docker VM though.
Second step is to use it.
Toolbox installed two very useful tools:
Toolbox also provides a convenient Docker Quickstart icon on the desktop. Clicking it launches a bash shell window. It also creates a default local Docker engine (a Boot2Docker VM on Windows) if it does not exist yet. Then it launches the default Docker engine. It prints the IP address of the Docker engine during the process:
On my Windows machine, the IP address of the default engine is 192.168.99.100 . This address will be useful when we want to connect to a running docker container for instance or if I want to log into the Docker engine.
We can now check our configuration, by running the hello world container. For this we simply need to type: docker run hello-word .
As explained in the output, this connects the Docker client to the default Docker engine. In that Docker engine, the Docker demon pulled the hello-world image from the Docker Hub registry. The Docker demon then created a container from that image, which created the output. Last, the Docker demon streamed this message back to the Docker client.
Before Docker Toolbox, we would have to first log on the Docker engine, and call the Docker demon inside that engine directly.
The new Docker client works directly from Windows. Just to be sure it is, let's run it from a Windows command prompt instead of the bash shell. First, we need to configure the command prompt to be able to connect to the default Docker engine. For this we type
docker-machine env default --shell cmd
in the bash window. The above command outputs how to configure a Windows command prompt:
We then open a Windows command prompt, and paste the following into it (we can also directly type the commands):
This configures the command prompt:
We can now try the hello world container from the command prompt:
This time the container is executed immediately as we have already downloaded the Docker image and created the container when we ran the command in the quickstart terminal.
Note that the docker client can also be launched from Windows Powershell. Same as for the command prompt, you need to configure your Powershell to work with the default engine we just created. For that, type the following in the quickstart terminal:
docker-machine env default --shell powershell
This will print the commands you need to run in a Powershell.
If you were fond of Boot2Docker you can still use it. Indeed, the default Docker engine on Windows is Bott2Docker. We can ssh to it via a simple call:
docker-machine ssh default
This will log us into the Boot2Docker machine.
We can now run the Docker demon inside this machine, for instance running the hello-world container once again.
We are all set. We can start downloading Docker images and run containers.
Let's pause for a second. What we have seen so far is three different ways to run Docker containers: from a bash shell in the quickstart terminal, from a windows command prompt, and from within a Boot2Docker machine. The latter was the only way so far, the former ones are new ways available directly from Windows.
Okay, we got more flexibility. Is that all Docker Toolbox has to offer? The answer is not, by far.
A major new feature is that the Docker client can work with several engines, locally, or remotely on a cloud. A list of supported cloud is provided here.
Even if you only use the docker client locally, then you may want to have several engines. For instance, if you want to create a larger engine to host your development environment, then you can use
docker-machine create -d virtualbox --vi
This creates a new Boot2Docker VM with 4 times more memory than default, 2 times more cpu than default, and 50GB of disk space instead of 20GB for default.
In order to use it, we need to reconfigure our Docker client. Remember that it is currently configured to connect to the default engine. As suggested by the output of the create command, we simply need to run the following to know what to do.
docker-machine env --shell cmd dev
We then cut and paste the suggested commands to our Windows command prompt. We then check we are indeed connected to a brand new Docker engine, by listing the Docker images in it.
There is none, while there should be at least the hello-world image if it was the default engine. This is how we can use a command prompt or a Powershell to interact with the new dev engine. However, we cannot use the quickstart terminal. I think it would be good to have an env --shell option to get the configuration commands for the quickstart terminal, for instance:
docker-machine env --shell bash dev
Anyway, this is not a show stopper. Let's configure our quickstart terminal manually. We start from the commands for the Windows command prompt:
We modify these to work with bash. The first modification is to use export to set environment variables. The second modification is to use a Linux style path:
We then cut and paste these into our quickstart terminal. We then check that we connect to our brand new dev engine by listing the Docker images.
There are none as expected.
We can try this new engine with the hello world example. After running it we list the images again.
Our new dev engine seems to be up and running!
We can now start using our dev engine. I'd start with a download one of the Jupyter images at http
For instance, let's pull the datascience notebook one as it contains lots of the Python packages I am working with:
docker pull jupy
Download starts, we can get a coffee, or even a lunch as this can take time depending on your network connection.
Once loaded then we will be able to run notebooks such as the Sudoku notebook I documented recently.
I will certainly also pull one of the spark image as well, for instance jupy
Last piece of advice. If you haven't really started, then you can simply remove the existing default engine and resize it. This way you do not need to reconfigure your quickstart terminal in order to use the new engine. Commands are:
docker-machine rm default