Tuesday, 24 November, 2020

3’s a Crowd - Getting Windows 10, Docker and VirtualBox to Live Together in Harmony.

How to install Docker on Windows 10 and use VirtualBox simultaneously

Who Should Read This

If you’re running an older version of Windows, earlier than Windows 10, stop reading now. This article isn’t for you. If you’re on Windows 10 and trying to use Docker and VirtualBox side by side, read on.

This article explains how to Install Docker Toolbox on Windows 10 and how to overcome and troubleshoot the common pitfalls.

Preamble

Installing Docker on Windows 10 is a cinch unless you want to use it alongside VirtualBox.

Modern versions of Docker on Windows 10 use Windows Hyper-V, see https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/about/, which is great except that Hyper-V doesn't play well with VirtualBox (https://www.virtualbox.org/), and trying to install both on Windows 10 is likely to break VirtualBox.

Side note: It's an issue which has been going on for a while. You can read the support ticket at https://www.virtualbox.org/ticket/16801. Recently some people have had success, but I didn't when I last tried 6 months ago and I expect support to remain patchy.

A Real-Life Scenario

In my case, I have legacy projects, configured to spin up virtualized environments using Vagrant, with Bash and Puppet provisioners, which I need to keep on ice for clients who may come calling asking for updates or fixes. But, I also have other clients and projects using Docker, and I want to be able to switch from one to the other, hassle free.

The Solution - Docker Toolbox Rides to the Rescue

Docker Toolbox - https://docs.docker.com/toolbox/toolboxinstallwindows/ - is the legacy Windows desktop solution for Docker which doesn’t use Hyper-V being instead built on VirtualBox, and you've guessed it, the workaround most people use is to install Docker using this legacy option, rather than the newer version.

The problem is it's not really meant for Windows 10 and so there are a few hiccoughs and the Docker QuickStart Terminal short-cut may not work. I list some of the more common issues and how to solve them below.

Side note: Alternatively you could use another Windows 10 computer; install a Linux partition and dual boot; try the Windows Linux Subsystem; install and uninstall Hyper-V as and when you need it; or try installing Docker inside a Linux VirtualBox machine.

Problem 1 – Are you running the wrong version of Virtual Box?

At the time of writing I downloaded v19.03.1 of Docker Toolbox from https://github.com/docker/toolbox/releases. This was released in July 2019 and supports Virtual Box 5.2.20. If you haven’t already installed VirtualBox it’ll be fine, you can install Docker Toolbox and the recommended version of VirutalBox (5.2.20) at the same time.

If you're already using VirtualBox like me, I have 6.0.14 installed, and want to keep using the same (presumably newer) version then you'll need to run the customised version of the Docker Toolbox installer and unselect VirtualBox from the install.

Side note: I deselected the Windows GIT installation too as that was already installed as well.

Problem 2 – The Desktop Short Cuts Don’t Work?

After installation you may find the desktop short-cuts created by the installer don't work.

This maybe because you chose not to install Git for Windows as part of the Toolbox installation, or because Git was not installed to the standard (path) location on your machine.

You can fix this by editing the short-cut and amending the Target to point to the correct location of your GIT bash executable: ...\Git\bin\bash.exe.

Problem 3 – Docker says Virtualisation isn’t installed?

The short-cut link works but when Docker runs it's start.sh file (using GIT bash) it fails with the message:

“This computer doesn't have VT-X/AMD-v enabled. Enabling it in the BIOS is mandatory"

The solution is to specify the virtualbox-no-vtx-check option when creating the VirtualBox environment.

Do this by going to the folder where you installed Docker Toolbox and editing the start.sh file (be careful with line endings and carriage returns), go to line 69, amend "${DOCKER_MACHINE}" create -d virtualbox $PROXY_ENV "${VM}" to "${DOCKER_MACHINE}" create -d virtualbox --virtualbox-no-vtx-check $PROXY_ENV "${VM}".

See this Stack Exchange question for more information: https://superuser.com/questions/1443294/docker-toolbox-doesnt-have-vt-x-amd-v-even-if-it-is-enabled.

Problem 4 - The Network Connection Fails

Despite VirtualBox working on your machine happily for eons, all of a sudden, and somewhat suspiciously after installing Docker Toolbox, it's may start having issues connecting to the network card.

You'll the a message with text like:

Failed to open/create the internal network 'HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter' (VERRINTNETFLTIFNOT_FOUND)

In this case the old IT support engineer fallback is your friend – reinstall the drivers. Go to Network Adapter settings (I right click the Windows icon, select Device Manager), expand Network Adapters, then select the VirtualBox network adapters and update the drivers for them using the Browse my Computer Driver Software option.

I know this is crazy but trust me it works.

For more information check this out: https://stackoverflow.com/questions/33725779/failed-to-open-create-the-internal-network-vagrant-on-windows10

Final Checks

Once the Docker Quick Start Terminal short-cut works and takes you to a command line run the docker run hello-world command to make sure everything works.

Closing Thoughts

Docker is becoming more and more prevalent.

If you're lucky enough to have more than one development machine or a Windows\Linux dual boot system then you'll be able get along by switching between environments like I did, but after a while it will probably grate enough for you to want to try and find a solution to make Docker and VirtualBox live side by side on Windows 10.

The good news is that it looks like VirtualBox are trying to solve this issue and will eventually release something which works and is stable when Hyper-V is installed. Then we can all use the latest Docker installation for Windows 10, based on Hyper-V, and get on with our lives.

In the meantime I recommend the solution and workarounds outlined above.

Want to Thank Me?

Did you like the article? Was it helpful? If so why not buy me a coffee using Paypal? Buy me a coffee at https://www.paypal.me/justaguycoding