How to use Vagrant and Docker-for-Windows on a Hyper-V system? Back in the day, I was using VirtualBox (VB) and Vagrant (V) to run VMs. Since I installed docker-for-windows (DfW) and run V, VB complains about Hyper-V (HV).

[user@localhost ~]$ vagrant up
Stderr: VBoxManage.exe: error: VT-x is not available (VERR_VMX_NO_VMX)
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component
ConsoleWrap, interface IConsole


Although this link indicates that V supports HV, the above error message is contradictive. Why does VB look incompatible with HV, why V says that it supports HV and how to prevent that HV needs to be disabled in order to use V again.

| Product    | Version |
|:-----------|--------:|
| Vagrant    |   2.0.1 |
| VirtualBox |   5.2.4 |
| Windows    |      10 | 


Discussion

The suggestion to switch Hyper-V on and off is not the preferred solution as it is time consuming.

If it would be possible to run V and DfW on the same system by replacing VB this could be an option.
Confirmed by this answer on SO referencing  Microsoft technet once Hyper-V is activated it mask the VT-X instructions of the processor to the OS on top of it and windows run like a guest.

Docker for Windows need hyper-V to work, so disabling it is not really an option.

There's no way to have virtual box running on top of Hyper-V and that's quite normal, you should not run an hypervisor within an hypervisor, they'll fight to orchestrate hardware acces.

The best workaround in my opinion is to create hyper-V virtual machine from vagrant with the hyper-V provider instead of virtual box machines, this way you can create VM or container on the same session.

Side note, vagrant already have a note about this in the hyper-v provider documentation page (found while searching the link to add above):


  Warning: Enabling Hyper-V will cause VirtualBox, VMware, and any other virtualization technology to no longer work. See this blog post for an easy way to create a boot entry to boot Windows without Hyper-V enabled, if there will be times you will need other hypervisors.