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.
Set-VMProcessor -VMName "<Your Virtual Machine Name>" -ExposeVirtualizationExtensions $trueReplace <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:
# Run inside the guest VM
Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -RestartStep 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:
# Run inside the guest VM
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
Install-Package -Name docker -ProviderName DockerMsftProvider
Restart-Computer -ForceOn 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:
Get-Service docker
docker run hello-worldA successful hello-world output confirms that Docker is reaching the Hyper-V isolation layer correctly.
Further Reading
- If you are containerising workloads with security in mind, hardening Docker for always-on use covers egress proxying, read-only root filesystems, and secrets isolation.
- Building Docker images across different CPU architectures is covered in multi-platform Docker builds using a Synology NAS as a remote builder.
Solution Architect with 30 years in cloud infrastructure, security, identity, and .NET engineering.