Created
February 2, 2026 08:48
-
-
Save ponfertato/36bf68510e39c5900d67dcb8d2dac18b to your computer and use it in GitHub Desktop.
powershell.exe -executionpolicy bypass -file "...\docker-clear-wsl.ps1"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $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