How to Increase Docker Disk Size in Windows (WSL 2 Backend)
If you are using Docker with WSL 2 backend and cannot increase the disk size from the Docker Desktop settings, follow these steps:
Step 1: Check Current Disk Size
-
Open PowerShell and run:
wsl --list --verboseThis will show the installed WSL distributions. Identify the distribution where Docker is installed (usually
docker-desktop-data). -
Shut down WSL:
wsl --shutdown
Step 2: Locate the WSL Disk Image
The WSL disk image is stored as a .vhdx file. By default, it is located in:
C:\Users\YourUsername\AppData\Local\Docker\wsl\data\ext4.vhdx
(Replace YourUsername with your actual Windows username.)
Step 3: Resize the WSL Disk
-
Open PowerShell as Administrator and run:
cd "C:\Users\YourUsername\AppData\Local\Docker\wsl\data\" wsl --shutdown -
Run diskpart:
diskpart -
Inside
diskpart, execute:select vdisk file="C:\Users\YourUsername\AppData\Local\Docker\wsl\data\ext4.vhdx" expand vdisk maximum=512000 exit(Change
512000to the required size in MB, e.g., 500GB =512000MB.)
Step 4: Resize the Filesystem Inside WSL
-
Start WSL again:
wsl -
Resize the file system:
sudo resize2fs /dev/sdX(Replace
/dev/sdXwith the correct partition name, which you can find usingdf -hinside WSL.)
Step 5: Restart Docker
- Restart Docker Desktop and check if the disk size has increased.
After following these steps, you should be able to allocate more space for Docker volumes.
Post Tags: