Skip to content
DevOps

How to Run Hyper-V and Docker Inside a Hyper-V Virtual Machine

4 min read
How to Run Hyper-V and Docker Inside a Hyper-V Virtual Machine

Key Takeaways

  • Nested virtualisation on Hyper-V requires a single PowerShell command on the host before the guest VM boots — it cannot be toggled while the VM is running
  • The guest VM must be at configuration version 8.0 or higher, and the physical host needs an Intel processor with VT-x and EPT
  • Docker Desktop on Windows now defaults to WSL2 and no longer requires Hyper-V on developer machines — but nested Hyper-V remains the correct path for Windows Server guests and headless virtualisation scenarios

Running Hyper-V inside a Hyper-V virtual machine sounds circular, but it is entirely supported and straightforward to enable. The use case comes up more often than you might expect: keeping a clean host OS while doing all development inside VMs, or running Docker on a Windows Server guest where WSL2 is not available.

Note on Docker Desktop: Since Docker Desktop 4.x, Windows desktop installations default to the WSL2 backend and no longer require Hyper-V on the host. If you are on a developer workstation running Windows 10 or 11, the WSL2 path is simpler. Nested Hyper-V is still the right approach for Windows Server guests, Hyper-V-isolated containers, and environments where WSL2 is unavailable or disallowed.

Prerequisites

Before enabling nested virtualisation, confirm the following:

  • Hyper-V host: Windows Server 2016 or Windows 10 Anniversary Update (or later)
  • Guest VM: Windows Server 2016 or Windows 10 Anniversary Update (or later)
  • VM configuration version: 8.0 or greater (check with Get-VM -Name "<name>" | Select-Object Version)
  • Processor: Intel with VT-x and EPT support (AMD EPYC and Ryzen support nested virtualisation from Windows Server 2022 / Windows 11 onwards)
  • VM state: powered off when you run the configuration command

How Do You Enable Nested Virtualisation?

Step 1 — Expose virtualisation extensions to the guest

On the physical Hyper-V host, run the following in an elevated PowerShell session. The VM must be off.

PowerShell
Set-VMProcessor -VMName "<Your Virtual Machine Name>" -ExposeVirtualizationExtensions $true

Replace <Your Virtual Machine Name> with the exact name shown in Hyper-V Manager.

Step 2 — Start the VM and install Hyper-V inside it

Start the VM, then install the Hyper-V role inside the guest exactly as you would on a physical server:

PowerShell
# Run inside the guest VM
Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -Restart

Step 3 — Install Docker

Once Hyper-V is active inside the guest, install Docker. On Windows Server 2016 and later, the recommended method is the PowerShell provider:

PowerShell
# Run inside the guest VM
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
Install-Package -Name docker -ProviderName DockerMsftProvider
Restart-Computer -Force

On Windows 10 guests you can use Docker Desktop with the Hyper-V backend (or WSL2 if available).

Verifying the Setup

After the restart, confirm Docker is running and can start a container:

PowerShell
Get-Service docker
docker run hello-world

A successful hello-world output confirms that Docker is reaching the Hyper-V isolation layer correctly.

Further Reading

David Christiansen
David Christiansen

Solution Architect with 30 years in cloud infrastructure, security, identity, and .NET engineering.

Related Posts