How to run Docker Desktop inside a Vmware Windows VM

How to run Docker Desktop inside a Vmware Windows VM

Prerequisites

  1. Physical Host Requirements: Ensure the physical ESXi host’s CPU supports hardware-assisted virtualization (Intel VT-x with EPT or AMD-V with RVI). Most modern CPUs support this, but it must also be enabled in the host’s BIOS.
  2. ESXi Version: These instructions apply to ESXi 6.7 or later, though the process is similar for earlier versions like 5.1 and above with slight UI differences.
  3. Access: You’ll need administrative access to the ESXi host or vCenter managing it, typically via the vSphere Client (web interface).

Steps to Enable Nested Virtualization

  1. Power Off the VM
    Nested virtualization settings can only be modified when the Windows VM is powered off. In the vSphere Client, locate your Windows VM, right-click it, and select “Power Off.”
  2. Edit VM Settings
    • Right-click the powered-off VM and choose “Edit Settings.”
    • Navigate to the Virtual Hardware tab and expand the CPU section.
  3. Enable Hardware-Assisted Virtualization
    • Check the box labeled “Expose hardware-assisted virtualization to the guest OS”.
      • This option allows the Windows VM to access the CPU’s virtualization extensions (e.g., Intel VT-x or AMD-V), which are required for running nested VMs or a hypervisor like Hyper-V.
    • If this option is grayed out, it could mean:
      • The VM’s hardware compatibility is set too low (e.g., pre-ESXi 5.1). Update it to a newer version (e.g., ESXi 6.7 or later) under the “Compatibility” section.
      • The physical CPU lacks support for nested virtualization, or it’s disabled in the BIOS.
  4. Optional: Adjust CPU/MMU Virtualization
    • In the same CPU section, you may see an option for “CPU/MMU Virtualization”. Set it to “Hardware CPU and MMU” for optimal performance with nested virtualization. This ensures the guest OS uses the hardware’s full virtualization capabilities.
  5. Enable Hyper-V Support (if applicable)
    • If your goal is to run Hyper-V inside the Windows VM, you’ll need to add an additional configuration parameter:
      • Go to the VM Options tab, expand Advanced, and click “Edit Configuration”.
      • Add the following key-value pair:
        • Key: hypervisor.cpuid.v0
        • Value: FALSE
      • This tricks the Windows guest into thinking it’s running on physical hardware, enabling Hyper-V to function.
    • Click “OK” to save the configuration.
  6. Networking Considerations
    • If your nested VMs need network access, ensure the virtual switch (vSwitch) or port group connected to the Windows VM allows promiscuous mode:
      • In the vSphere Client, go to the ESXi host > Configure > Virtual Switches.
      • Edit the vSwitch or port group settings, set Promiscuous Mode to Accept, and save.
    • This is necessary for nested VM traffic to pass through the outer VM’s virtual network adapter.
  7. Save and Power On
    • Click “OK” to save all changes to the VM settings.
    • Power on the Windows VM.
  8. Verify in Windows
    • Once the Windows VM boots, verify that nested virtualization is enabled:
      • Open a Command Prompt or PowerShell as Administrator and run:
        systeminfo
      • Look under “Hyper-V Requirements.” If it says “A hypervisor has been detected,” Hyper-V is active. If not, ensure the settings above were applied correctly.
    • Alternatively, install Hyper-V (via “Turn Windows features on or off”) and try creating a test VM to confirm it works.

One comment

  1. Pingback: How to setup Aspire to use a local SQL Server container – Stuff I don't want to forget :)

Leave a Reply

Your email address will not be published. Required fields are marked *