Tag: WSL

  • How to shrink Docker Virtual Harddisk: docker_data.vhdx

    I just discovered that I had a >120 GB VHDX file in “%LOCALAPPDATA%\Docker\wsl\disk\docker_data.vhdx“).

    According to the description of Ahmed Moussa on dev.to (and some other articles), this is the virtual hard disk when using Docker for Windows and WSL. The Virtual Harddisk is dynamically increasing when needed. Unfortunately not decreasing.

    To compact and reclaim free space, perform those steps:

    1. Prune docker (see the FAQ)
      docker system prune -a --volumes
      this freed ~15 GB
    2. Compact the virtual Hard disk(s) (VHDX)
      • Stop Docker: “Quit Docker Desktop” from the Tray Icon
      • Shut Down WSL:
        wsl --shutdown
      • Compact the VHDX in Powershell (manual page):
        Optimize-VHD -Path "PATH/TO/VHDX" -Mode Full
        (Reclaimed ~85 GB)

    Fediverse Reactions