13

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.

030
  • 13,383
  • 17
  • 76
  • 178

3 Answers3

9

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.

Tensibai
  • 11,416
  • 2
  • 37
  • 63
5

A few years later this thread is still the first result in Google, but running Docker+Vagrant (with VirtualBox) on Windows isn't a challenge anymore. You can easily run them both, as described here

If for some reason you want to use Vagrant with VirtualBox as a provider you should update to VB 6.x - after that, you can run VirtualBox, Vagrant, and Docker at the same time. Just configure your VM to use Hyper-V as Paravirtualization Interface. You can do it by VirtualBox GUI (VM's Settings -> System -> Acceleration -> Paravirtualization Interface) or by using Vagrantfile:

Vagrant.configure("2") do |config|
  # your config (…)
  config.vm.provider "virtualbox" do |vb|
    vb.customize [
      "modifyvm", :id,
       " - paravirtprovider", "hyperv"
    ]
  end
  # your config (…)
end

This will work not only for Windows Enterprise/Pro/Edu but also for Home Edition (with WSL2 as Docker Backend). This solution shouldn't break your VirtualBox's machine, so you don't have to switch hypervisorlaunchtype over and over again.

Pierre.Vriens
  • 7,225
  • 14
  • 39
  • 84
kubut
  • 151
  • 1
  • 1
0

Alongside Vagrant, you could use the old school Legacy 'Docker Toolbox' instead of 'Docker for Windows'. That means Docker will be slow since its running in a Linux VM I believe. https://docs.docker.com/toolbox/toolbox_install_windows/ Other than that, yes I have been restarting my computer everything i need HyperV for Docker or remove it when i want vagrant.