I was surprised to experience that VirtualBox and docker's HyperKit can run VMs at the same time on OS X. Using different hypervisors at the same is not possible on Windows or Linux. How come it works on OS X?
41 Answer
Let me try to answer this not-very-simple question.
There are two types of hypervisors, as summarized byWikipedia:
Type-1, native or bare-metal hypervisors
These hypervisors run directly on the host's hardware to control the hardware and to manage guest operating systems. For this reason, they are sometimes called bare metal hypervisors.
Type-2 or hosted hypervisors
These hypervisors run on a conventional operating system (OS) just as other computer programs do.
Hyper-V is type 1, which means that it when installed becomes the computer. Installing the Hyper-V feature in effect relegates the installed Windows version to being just a virtual machine, which is however allocated 100% of the hardware resources.
VirtualBox and VMWare for Windows are type 2, meaning that they work under Windows as normal programs, where CPUs are emulated as threads, so could in theory still run under a type 1 hypervisor such as Hyper-V.
The problem arises when hardware virtualization assistance is used for the emulation of dissimilar CPUs, namely Intel VT-x and AMD-V. Such hardware is required for emulating, for example, a 32-bit CPU on a 64-bit computer.
Hardware virtualization can have only one owner (or user). This means that only one hypervisor can use it at any one time and precludes having two type 2 hypervisors running on the same computer.
In addition, specifically for the mentioned Docker, this is not a hypervisor. As Wkipedia explains:
Docker is a computer program that performs operating-system-level virtualization, also known as "containerization".
Docker does not do any CPU or device emulation, but supplies a thin layer for translating containerized operating system calls to host operating system calls. Containers are very limited in how much their operating system can diverge form that of the host, as it must be similar enough for simple and light translation of the calls. Docker therefore doesn't conflict with hypervisors on hardware usage.
2