HowTo: Run Hyper-V/Docker on Hyper-V Virtual Machine

TL:DR; On the Hyper-V host run  Set-VMProcessor -VMName "<Your Virtual Machine Name>" -ExposeVirtualizationExtensions $true

If you are like me, you may run all your Dev Environments from within Virtual Machines, leaving your base OS install as clean as possible – albeit with MS Office, Browsers etc. installed.

In recent projects I’ve been working with containerisation of system deployments with Docker. This has required me to have docker installed on my Virtual Machines.  In order to run docker on Windows 10, i’ve needed to have Hyper-V installed… Hyper-V running on a VM !?  Yup, it’s possible!

Prerequisites

  • A Hyper-V host running Windows Server 2016 or Windows 10 Anniversary Update;
  • A Hyper-V VM running Windows Server 2016 or Windows 10 Anniversary Update;
  • A Hyper-V VM with configuration version 8.0 or greater;
  • An Intel processor with VT-x and EPT technology.

Configure Nested Virtualisation

  1. Create a virtual machine.
  2. While the virtual machine is in the OFF state, run the following command on the physical Hyper-V host. This enables nested virtualisation for the virtual machine.
    Set-VMProcessor -VMName "<Your Virtual Machine Name>" -ExposeVirtualizationExtensions $true
  3. Start the virtual machine.
  4. Install Hyper-V within the virtual machine, just like you would for a physical server.