Skip to content

Instantly share code, notes, and snippets.

@micahyoung
Last active April 21, 2020 11:51
Show Gist options
  • Save micahyoung/d8649ec8a5ac6493333dc6d02722d501 to your computer and use it in GitHub Desktop.
Save micahyoung/d8649ec8a5ac6493333dc6d02722d501 to your computer and use it in GitHub Desktop.
Windows Docker Daemon VM

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 10 ISO Image

  4. Install Windows 10 VM

    • File -> New -> Pick Windows 10 iso
    • Choose a password
    • Choose: Windows 10 Pro
    • Customize Settings:
      • Save to default location
      • Change Network Adapter to use your new network adapter (ex: vmnet2)
      • Change RAM to at least 8192: Customized Settings -> Processors...
      • Enabled nested virtualization: Customize Settings -> Processors... -> Advanced Options -> Enable hypervisor applications...
  5. Start Windows 10 VM

  6. Optional: Shutdown, Create Snapshot, Restart, Login

On Windows 10 VM

  1. Perform First-time VM setup

    • Log-off/Restart VM if prompted by dialogs
    • Install Updates (Start Menu -> Type "Updates" -> Check for Updates -> Install Now)
  2. Open this page on VM in Edge browser

  3. Download Docker for Windows

  4. Install Docker for Windows

    • Check "Use Windows Containers instead of Linux Containers..."
    • Choose "Close and Logout" at the end
  5. Log in again after machine reboots

    • Wait for Docker to start
    • Note: some versions require an extra reboot to enable Hyper-V
  6. Enable Docker Daemon TCP listening

    • Docker Tray Icon -> Menu -> Settings -> Expose daemon on tcp://localhost:2375...
    • Click Apply
    • Manually restart: Right-click docker tray icon -> Restart (to ensure setting applies restarts)
  7. Optional: Enable Insecure registries for VM IP

    • Docker Tray Icon -> Menu -> Settings -> Docker Engine
      • Add: "192.168.2.0/24" to "insecure-registries":[],
      • This allows registry containers to be run and pushed to from the Host
  8. Open Administrator Powershell

    • Right-click Windows Icon -> Windows Powershell (Admin)
  9. In Admin Powershell, add public port forward port, pointing to local docker port

    netsh interface portproxy add v4tov4 listenport=23750 connectport=2375 connectaddress=127.0.0.1
    
  10. In Admin Powershell, add firewall rule

    New-NetFirewallRule -DisplayName DockerPublic -LocalPort 23750 -Protocol TCP
    
  11. Optional: Shutdown, Create Snapshot, Restart, Login

  12. In Admin Powershell, get IP address

    "DOCKER_HOST=tcp://"+(Get-NetIPAddress -InterfaceAlias Ethernet0 -AddressFamily IPv4).IPAddress+":23750"
    

On Mac workstation

  1. Open Terminal

  2. In Terminal, set DOCKER_HOST

    export DOCKER_HOST="tcp://<vm ip address>:23750"
    
  3. In Terminal, test Docker

    docker info
    
    # Expected output
    Client:
    Debug Mode: false
    
    Server:
    Containers: 0
     Running: 0
     Paused: 0
     Stopped: 0
    Images: 1
    Server Version: 19.03.2
    Storage Driver: windowsfilter
     Windows:
    Logging Driver: json-file
    Plugins:
     Volume: local
     Network: ics l2bridge l2tunnel nat null overlay transparent
     Log: awslogs etwlogs fluentd gcplogs gelf json-file local logentries splunk syslog
    Swarm: inactive
    Default Isolation: hyperv
    Kernel Version: 10.0 17763 (17763.1.amd64fre.rs5_release.180914-1434)
    Operating System: Windows 10 Enterprise Evaluation Version 1809 (OS Build 17763.379)
    OSType: windows
    Architecture: x86_64
    CPUs: 1
    Total Memory: 4GiB
    Name: MSEDGEWIN10
    ID: 5MKL:VDT7:YM72:IFOB:YTIC:2NTH:5YUO:VNN6:VMII:SUR7:DNQI:REVH
    Docker Root Dir: C:\ProgramData\Docker
    Debug Mode: true
     File Descriptors: -1
     Goroutines: 27
     System Time: 2019-10-09T09:04:13.5781811-07:00
     EventsListeners: 1
    Registry: https://index.docker.io/v1/
    Labels:
    Experimental: false
    Insecure Registries:
     127.0.0.0/8
    Live Restore Enabled: false
    Product License: Community Engine
    

Troubleshooting

If you can connect to the Docker Daemon but can't connect to any published container port, it may be related to this. I tried several workarounds but the only re-creating VM from scratch worked.

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment