Monday, 15 June, 2020

4's a Crowd - Getting Windows 10, Docker, Hyper-V and VirtualBox working together (Part 2)

How to install Hyper-V or Docker on Windows 10 and still use VirtualBox using Boot Menu Options

Who Should Read This

If you’re on Windows 10 and trying to use Docker, Hyper-V, and VirtualBox all together on the same machine at the same time, then this article is for you.

Preamble

I wrote an article a month ago explaining how to install Docker on Windows 10 and continue to use VirtualBox (see https://justaguycoding.com/jagc-blog/posts/win10dockervbox/).

This was an issue, for me, as I have legacy software development environments using Vagrant and VirtualBox. Since writing the article and using the set-up explained in it I've changed the way I work and wanted to report back.

The Problem

The problem is Microsoft's Hyper-V and VirtualBox don't work at the same time on the same system.

This is because Hyper-V is a type-1 bare metal Hypervisor and VirtualBox is a type-2 (OS) hosted Hypervisor, meaning Hyper-V starts first and runs Windows 10 as a "special virtual server" preventing VirtualBox from accessing the underlying Intel VT-X capabilities. Read more about it on https://superuser.com/questions/1208850/why-cant-virtualbox-or-vmware-run-with-hyper-v-enabled-on-windows-10.

The issue is brought to a head when you try to install and use Docker on a system where VirtualBox is already in use.

The Solution

If you need a solution where both Docker and Virtualbox need to work together at the same time take a look at https://justaguycoding.com/jagc-blog/posts/win10dockervbox/.

If you don't need to use Hyper-V or Docker and VirtualBox to work at the same time, on the same machine, then one solution is to boot your machine with Hyper-V running or not as and when you need to use it.

It turns out this is fairly easy to set-up, and you don't need to uninstall VirtualBox when you install Hyper-V because when Hyper-V isn't running VirtualBox will run and work just fine.

The tool for managing boot settings is BCDEdit see https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/bcdedit-command-line-options for the full rundown.

Here's how to configure Windows 10 to "dual boot" and provide options for running with and or without Hyper-V:

  • Firstly, install Hyper-V. Hint: copy and paste "Control Panel\Programs\Programs and Features" into Windows Explorer and select "Turn Windows Features on or off".
  • Next, run the Windows command prompt as an administrator. Hint: don't use Powershell.
  • Type bcdedit for an output giving your current boot loaders.
  • Type: bcdedit /copy {current} /d "No Hyper-Visor" . You'll see something like the entry was successfully copied to {49916baf-0e08-11db-9af4-000bdbd316a0}.
  • Type: bcdedit /set {49916baf-0e08-11db-9af4-000bdbd316a0} hypervisorlaunchtype off

Now when you reboot your machine you'll be given the option to boot with Hyper-V or without it. The default configuration here is to boot with Hyper-V enabled.

Find out more about adding boot entries and how to configure them at https://docs.microsoft.com/en-us/windows-hardware/drivers/devtest/adding-boot-entries.

Closing Thoughts

I find this solution more convenient than using the legacy Docker Toolbox and VirtualBox without installing Hyper-V because it allows me to use Hyper-V with new projects.

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

InterServer Web Hosting and VPS