Setting up Docker for Windows

Docker for Windows using Toolbox

I had trouble setting up Docker on my 64bit Windows 10 Pro computer using the Docker for Windows install. So, I decided to make my own post about how I was able to set up Docker (by using Toolbox instead)!

Windows 10 64-bit Professional/Enterprise/Education versions all include Hyper-V for virtualization (thereby supporting Docker natively). However, I couldn’t get it to work for some reason. So, I needed to install the Docker Toolbox, which uses Oracle VirtualBox. VirtualBox will act as the Hypervisor instead of Hyper-V.

Docker Toolbox is regularly updated with the Latest Docker Engine releases so don’t worry too much about that. But do note that Hyper-V is not compatible with VirtualBox so you won’t be able to run them simultaneously. It’s recommended to use Docker for Windows, you can grab the Community Edition here, but I have found it easier for me to use Toolbox.

Docker Toolbox includes:

  • Docker Machine for running docker-machine commands
  • Docker Engine for running the docker commands
  • Docker Compose for running the docker-compose commands
  • Kitematic, the Docker GUI
  • a shell preconfigured for a Docker command-line environment
  • Oracle VirtualBox

Installers

Grab the Docker Toolbox here

https://docs.docker.com/toolbox/overview/#ready-to-get-started

Follow the install wizard to install. VirtualBox comes bundled in, but if you already have it you can deselect it during installation.

Check the install

Open a terminal.

Make sure you can run the following commands:

docker --version

docker-compose --version

docker-machine --version

Your output should be similar to the following:

docker-commands1.PNG

You should also see the following new applications: Docker Toolbox, VirtualBox, and Kitematic.

I was getting some errors trying to run some Docker commands, even though everything had installed properly.  It looked something like this:

error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.26/containers/json: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.

There’s actually a whole discussion around the issue on GitHub here.

It seems I needed a VM running under docker-machine before I could run any commands. The error was indicating I had a client installed, but no engine running. So, to solve this I needed to create a VM. So I ran the following commands in terminal (where box is our machine name)

docker-machine create box

followed by:

docker-machine env box

This will verify it worked and out print the export commands that can be run.

 

Test solution

You should now be able to run the hello-world example from Docker with the following command:

docker run helloworld

and you’ll get your output as described in the Docker Starter guide:

 $ docker run hello-world
 Unable to find image 'hello-world:latest' locally
 Pulling repository hello-world
 91c95931e552: Download complete
 a8219747be10: Download complete
 Status: Downloaded newer image for hello-world:latest
 Hello from Docker.
 This message shows that your installation appears to be working correctly.

 To generate this message, Docker took the following steps:
  1. The Docker Engine CLI client contacted the Docker Engine daemon.
  2. The Docker Engine daemon pulled the "hello-world" image from the Docker Hub.
     (Assuming it was not already locally available.)
  3. The Docker Engine daemon created a new container from that image which runs the
     executable that produces the output you are currently reading.
  4. The Docker Engine daemon streamed that output to the Docker Engine CLI client, which sent it
     to your terminal.

 To try something more ambitious, you can run an Ubuntu container with:
  $ docker run -it ubuntu bash

 For more examples and ideas, visit:
  https://docs.docker.com/userguide/

Voilà!

 

 

 

 

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s