Installing Docker on Windows

I recently set up Docker on both Windows 10 and Windows 7.  In both cases, it was a slightly bumpy experience, so I am recording the steps I followed here.

Windows 10

Machine Specifications
  • 64-bit Windows 10
  • VT-X/AMD-v support enabled in the BIOS
  • Hyper-V installed
  • Latest version of VirtualBox (version 5.0.16 at the time of this writing) installed
Process

STEP 1

Download and install Docker Toolbox.  This is straightforward, and detailed instructions for doing this are available online).

STEP 2

Docker on Windows requires VirtualBox in order to run a lightweight Linux virtual machine.  VirtualBox and the Windows Hyper-V technology are mutually exclusive technologies; you cannot use both at the same time.  Therefore, If Hyper-V is installed and enabled on your machine, you should disable it by following the directions found here.

STEP 3

The Docker startup script checks for the presence of Hyper-V, and halts if it is found.  It does NOT check the enabled/disabled state of Hyper-V.  So, if Hyper-V is installed on your computer, add a parameter to the Docker startup script to avoid the Hyper-V check.

  1. Locate the file C:\Program Files\Docker Toolbox\start.sh, and make a backup copy.
  2. Open the file C:\Program Files\Docker Toolbox\start.sh for editing.
  3. Look for this line: "${DOCKER_MACHINE}" create -d virtualbox "${VM}"
  4. Add a parameter to the line: "${DOCKER_MACHINE}" create –virtualbox-no-vtx-check -d virtualbox "${VM}"
  5. Save the file
    STEP 4

The Docker Toolbox installation adds an icon to the desktop labeled “Docker Quickstart Terminal”.  Click on this icon to run Docker for the first time. 

At this point the script will create the Docker virtual machine and attempt to configure it.  If the configuration proceeds successfully, you will have a running Docker instance.

In my case, configuration failed.  I received the following error, which seems to be not uncommon:

Error creating machine: Error in driver during machine creation: Unable to start the VM: C:\Program Files\Oracle\VirtualBox\VBoxManage.exe startvm default –type headless failed:

VBoxManage.exe: error: Failed to open/create the internal network ‘HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter #5’ (VERR_INTNET_FLT_IF_NOT_FOUND).

VBoxManage.exe: error: Failed to attach the network LUN (VERR_INTNET_FLT_IF_NOT_FOUND)

VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component ConsoleWrap, interface IConsole

Details: 00:00:03.020271 Power up failed (vrc=VERR_INTNET_FLT_IF_NOT_FOUND, rc=E_FAIL (0X80004005))

To fix this error, I followed the instructions at https://caffinc.github.io/2015/11/fix-vbox-network/ to change the properties of the VirtualBox network adapter.  The key instructions are repeated here:

I opened my Control Panel > Network & Internet > Network Connections and located my VirtualBox Host-Only Network adapter, called VirtualBox Host-Only Network #6 on my machine. I right-clicked it and selected the Properties, and checked the un-checked VirtualBox NDIS6 Bridged Networking Driver and started VirtualBox again.

Then I used the VirtualBox Manager to delete the Docker virtual machine (named "default") and delete all associated files.

Once that additional configuration was complete, I was able to re-run the “Docker Quickstart Terminal” successfully.

Windows 7

Machine Specifications
  • 64-bit Windows 7
  • VT-X/AMD-v support enabled in the BIOS.
  • Latest version of VirtualBox (version 5.0.16 at the time of this writing) installed
Process

STEP 1

Download and install Docker Toolbox.

STEP 2

The Toolbox installation adds an icon to the desktop labeled “Docker Quickstart Terminal”.  Click on this icon to run Docker for the first time.  

At this point the script will create the Docker virtual machine and attempt to configure it.  If the configuration proceeds successfully, you will have a running Docker instance.

My configuration failed.  I received the following error:

Running pre-create checks…
Creating machine…
(default) Copying C:\Users\mlichtenberg\.docker\machine\cache\boot2docker.iso to
C:\Users\mlichtenberg\.docker\machine\machines\default\boot2docker.iso…
(default) Creating VirtualBox VM…
(default) Creating SSH key…
(default) Starting the VM…
(default) Check network to re-create if needed…
(default) Windows might ask for the permission to create a network adapter. Some
times, such confirmation window is minimized in the taskbar.
(default) Creating a new host-only adapter produced an error: C:\Program Files\O
racle\VirtualBox\VBoxManage.exe hostonlyif create failed:
(default) 0%…
(default) Progress state: E_INVALIDARG
(default) VBoxManage.exe: error: Failed to create the host-only adapter
(default) VBoxManage.exe: error: Assertion failed: [!aInterfaceName.isEmpty()] a
t ‘F:\tinderbox\win-5.0\src\VBox\Main\src-server\HostNetworkInterfaceImpl.cpp’ (
74) in long __cdecl HostNetworkInterface::init(class com::Bstr,class com::Bstr,c
lass com::Guid,enum __MIDL___MIDL_itf_VirtualBox_0000_0000_0036).
(default) VBoxManage.exe: error: Please contact the product vendor!
(default) VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component Ho
stNetworkInterfaceWrap, interface IHostNetworkInterface
(default) VBoxManage.exe: error: Context: "enum RTEXITCODE __cdecl handleCreate(
struct HandlerArg *)" at line 71 of file VBoxManageHostonly.cpp
(default)
(default) This is a known VirtualBox bug. Let’s try to recover anyway…
Error creating machine: Error in driver during machine creation: Error setting u
p host only network on machine start: The host-only adapter we just created is n
ot visible. This is a well known VirtualBox bug. You might want to uninstall it
and reinstall at least version 5.0.12 that is is supposed to fix this issue

To attempt to fix this error, I first followed the instructions at https://caffinc.github.io/2015/11/fix-vbox-network/ to change the properties of the VirtualBox network adapter.  The key instructions are repeated here:

I opened my Control Panel > Network & Internet > Network Connections and located my VirtualBox Host-Only Network adapter, called VirtualBox Host-Only Network #6 on my machine. I right-clicked it and selected the Properties, and checked the un-checked VirtualBox NDIS6 Bridged Networking Driver and started VirtualBox again.

This did NOT work.  However, I found additional advice online that suggested doing the opposite (checking the “VirtualBox NDIS6 Bridged Networking Driver” instead of unchecking), and then disabling and enabling the network adapter.

Disabling and re-enabling the network adapter may have been the key to resolving the error, but I cannot sure for sure.  In any case, I had success after 1) putting the properties of the network adapter back to their original state 2) and re-starting the network adapter.

Once the network adapter was reset, I used the VirtualBox Manager to delete the Docker virtual machine (named "default") and delete all associated files.

Once the additional configuration was complete, I was able to re-run the “Docker Quickstart Terminal” successfully.

Testing / Validation

On both Windows 7 and Windows 10, once the Docker installation completes successfully you will be left with a terminal window opened to a Docker command line.

An Internet connection is required for the following.

To test a basic Docker image, run the following command:

docker run hello-world

You will receive output that looks like the following:

Unable to find image ‘hello-world:latest’ locally
511136ea3c5a: Pull complete
31cbccb51277: Pull complete
e45a5af57b00: Pull complete
hello-world:latest: The image you are pulling has been verified.
Important: image verification is a tech preview feature and should not be
relied on to provide security.
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 client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
   (Assuming it was not already locally available.)
3. The Docker daemon created a new container from that image which runs the
   executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
   to your terminal.

 

That is it.  For next steps with Docker, reading the User’s Guide is a good place to start. 

If you want skip the specifics of Docker itself and dive right in to using a Docker container, pre-built Docker images for popular technologies such as nginx, Mongo, MySQL, Node, PostgreSQL, SOLR, ElasticSearch, and many others can be found at the Docker Hub.

8 Responses to Installing Docker on Windows

  1. Hi there, I think your site might be having browser compatibility issues.
    When I take a look at your web site in Safari, it looks fine
    but when opening in I.E., it’s got some overlapping issues.

    I simply wanted to provide you with a quick heads up! Apart from that, fantastic blog!

    • mlichtenberg says:

      Thanks for letting me know. As this is a wordpress.com-hosted blog, I am not sure there is much that I can do about layout issues. Just in case, though, what version of IE are you using? And is there a particular blog post that you are seeing problems with? I have just looked over the site with IE 11 and the Edge browser that comes with Windows 10, and did not see any problems.

  2. Dron says:

    Unfortunately your scenario for Win7 doesn’t work for me, I still get error even when I try to add host-only adapter manually in VirtualBox. Cannot use Docker because of that.

    • mlichtenberg says:

      Sorry to hear that. My experience getting it set up was pretty nightmarish, and involved a lot of trial-and-error. I blogged about it in the hopes that it might help someone else… unfortunately, even with what I wrote there may still be some trial-and-error involved. I was able to follow my own instructions to get Docker running on a second Windows 7 machine, but I am (unfortunately) not too surprised to hear that it did not work perfectly for someone else. Hopefully it got you close enough that you can figure it out?

      Incidentally, less than a month after I wrote that post, Docker released a completely new version that runs on later versions of Windows and uses Hyper-V instead of VirtualBox. I have found installing and using that version to be painless. If you have the option of running Docker on Windows 10, I highly recommend it over Windows 7.

  3. Hi, thank you for you troubleshoting on Win7. Restart adapter and remove default image helped 😉

  4. Step 3, Item 4 – Add a parameter to the line: “${DOCKER_MACHINE}” create –virtualbox-no-vtx-check -d virtualbox “${VM}”

    Did not work for me in Windows 10. I had to use below parameter.

    “${DOCKER_MACHINE}” create -d virtualbox –virtualbox-no-vtx-check “${VM}”

Leave a reply to Delfin Devassy Cancel reply