Skip to content

Instantly share code, notes, and snippets.

@Jacobboogiebear
Created April 2, 2023 17:26
Show Gist options
  • Save Jacobboogiebear/ffc407a6af2c7d2a02c3c7603b13f67c to your computer and use it in GitHub Desktop.
Save Jacobboogiebear/ffc407a6af2c7d2a02c3c7603b13f67c to your computer and use it in GitHub Desktop.
Batch scripts to optimize Docker Desktop storage on Windows 10/11 (requires Hyper-V enabled, for Windows 11 home use this script to enable: https://gist.github.com/Jacobboogiebear/24b46aa0c5587db50673403c4117a5bf)
@echo off
set "params=%*"
cd /d "%~dp0" && ( if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" ) && fsutil dirty query %systemdrive% 1>nul 2>nul || ( echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~sdp0"" && %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" && "%temp%\getadmin.vbs" && exit /B )
taskkill /F /IM "Docker Desktop.exe" /T
wsl --shutdown
powershell -Command "Optimize-VHD -Path %LOCALAPPDATA%\\Docker\\wsl\\data\\ext4.vhdx"
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment