Skip to content

Instantly share code, notes, and snippets.

@ponfertato
Created February 2, 2026 08:48
Show Gist options
  • Select an option

  • Save ponfertato/36bf68510e39c5900d67dcb8d2dac18b to your computer and use it in GitHub Desktop.

Select an option

Save ponfertato/36bf68510e39c5900d67dcb8d2dac18b to your computer and use it in GitHub Desktop.
powershell.exe -executionpolicy bypass -file "...\docker-clear-wsl.ps1"
$LOCAL = "$env:LOCALAPPDATA\Docker\wsl"
$VHD1 = Join-Path $LOCAL "disk\docker_data.vhdx"
$VHD2 = Join-Path $LOCAL "main\ext4.vhdx"
docker system prune -f
docker run --rm --privileged --pid=host docker/desktop-reclaim-space
docker rmi docker/desktop-reclaim-space -f
Get-Process -Name "Docker Desktop","com.docker.backend","com.docker.build" -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
wsl --shutdown
if (Test-Path $VHD1) { Optimize-VHD -Path $VHD1 -Mode Full }
if (Test-Path $VHD2) { Optimize-VHD -Path $VHD2 -Mode Full }
Start-Sleep -Seconds 2
Start-Process -FilePath "$env:ProgramFiles\Docker\Docker\Docker Desktop.exe" -ErrorAction SilentlyContinue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment