What is ext4.vhdx?
Located deep inside your Windows AppData folder (usually at C:\Users\[Name]\AppData\Local\Docker\wsl\data\ext4.vhdx), this is a single, massive file that can easily grow to 50GB, 100GB, or even 250GB, consuming your entire C:\ drive.
Why Does It Exist?
If you are a software developer using Docker Desktop or WSL2 (Windows Subsystem for Linux), Windows creates this Virtual Hard Disk (.vhdx) file to act as the “fake” Linux hard drive.
Every time you pull a Docker image, build a container, or spin up a local PostgreSQL database inside Docker, all of that data is saved directly inside the ext4.vhdx file.
Can You Delete It?
No. Absolutely not.
Deleting this file is the exact equivalent of taking a sledgehammer to a Linux server’s hard drive.
What Happens If You Delete It?
If you forcefully delete the ext4.vhdx file:
- Docker Desktop will instantly crash and refuse to boot.
- Every single Docker image, container, and volume you ever created will be permanently destroyed.
- Any local development databases (like MySQL or Postgres running in Docker) and their data will be wiped out with zero chance of recovery.
How to Safely Shrink It
The biggest problem with ext4.vhdx is that it grows automatically when you download Docker images, but it never shrinks, even if you delete the images! To reclaim the space safely, you must manually compress the virtual drive:
- Open PowerShell as Administrator.
- Shut down Docker and WSL:
wsl --shutdown - Open the DiskPart tool:
diskpart - Select the file:
select vdisk file="C:\Users\YourName\AppData\Local\Docker\wsl\data\ext4.vhdx" - Compress it:
compact vdisk - Exit:
exit
Bottom Line
Never manually delete ext4.vhdx via File Explorer unless you are entirely prepared to permanently lose every single Docker container, image, and database on your machine. Use the diskpart compact command to safely shrink it instead.
Discussion
Loading authentication...