Skip to content

Windows Docker Daemon on Fusion VM

Javier Romero edited this page Mar 31, 2022 · 20 revisions

Purpose

Allow a MacOS workstation to run a local Docker for Windows daemon in a VMware Fusion¹ Virtual Machine that is accessible by setting DOCKER_HOST.

On Mac workstation

  1. Download and Install VMware Fusion
  2. Create a new Fusion Network Interface
    • Open Fusion
    • VMWare Fusion Menu -> Preferences -> Network tab -> Unlock -> + (Add Network)
      • Default name is vmnet2
    • New network adapter:
      • Enable NAT: Allow virtual machines ... (using NAT)
      • Subnet IP: 192.168.2.0
      • Click Apply
  3. Download Windows Server 2019 VHD Image
  4. Install Windows VM
    • File -> Import -> Choose File -> Pick your VHD
    • Customize Settings:
      • General:
        • Memory: 4GB or more
        • CPU: 2 processors or more
        • Enable hypervisor applications
      • Network Adapter: use your new network adapter (ex: vmnet2)
  5. Start Windows VM
  6. Optional: Shutdown, Create Snapshot, Restart, Login

On Windows VM

  1. Perform First-time VM setup
    • Log-off/Restart VM if prompted by dialogs
    • Install Updates (Start Menu -> Type "Updates" -> Click "Check for Updates" -> Click "Install Now")
    • Enable Developer Mode (Start Menu -> Type "Dev" -> Click "Developer Settings" -> Select "Developer mode")
  2. Enable Remote Desktop (Administrator PowerShell)
    Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -value 0
    Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
  3. Install Docker for Windows (Administrator PowerShell)
    Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
    Install-Package -Name docker -ProviderName DockerMsftProvider -Force
    Restart-Computer -Force
  4. Wait for restart
  5. Optionally, setup up as a dev vm

Troubleshooting

If you can't connect to your VM, your new Adapter (vmnet2) may be conflicting with your default adapter (vmnet8) IP address range. Your best option is to set your default network to a different IP range: https://spin.atomicobject.com/2017/04/03/vmware-fusion-custom-virtual-networks/

Footnotes

¹ Fusion is used for its VT-x (nested hypervisor) support, which is required to run Docker for Windows. There appears to be no open-source hypervisor for MacOS currently with this feature.