Steps to install WSL 2:

  • Join the Windows Insider Program (required)
  • Enable required WSL components
  • Install a Linux distribution
  • Set the Linux distribution to use WSL 2
  • WSL 2 troubleshooting: compressed virtual disk files cannot be converted to the WSL 2 architecture
  • Install and start Docker
  • Install Docker Desktop v2.2.1.0
# Enable required WSL components
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

# Set the Linux distribution to WSL 2
wsl --set-version ubuntu 2
wsl --set-default-version 2

  • Edit %UserProfile%\.wslconfig

    • Command Prompt

      notepad %UserProfile%\.wslconfig
      
    • Windows PowerShell

      notepad $env:USERPROFILE\.wslconfig
      
  • Configuration reference

    [wsl2]
    kernel=<path>              # An absolute Windows path to a custom Linux kernel.
    memory=<size>              # How much memory to assign to the WSL2 VM.
    processors=<number>        # How many processors to assign to the WSL2 VM.
    swap=<size>                # How much swap space to add to the WSL2 VM. 0 for no swap file.
    swapFile=<path>            # An absolute Windows path to the swap vhd.
    localhostForwarding=<bool> # Boolean specifying if ports bound to wildcard or localhost in the WSL2 VM should be connectable from the host via localhost:port (default true).
    
    # <path> entries must be absolute Windows paths with escaped backslashes, for example C:\\Users\\Ben\\kernel
    # <size> entries must be size followed by unit, for example 8GB or 512MB
    
  • Related links