Do Not Delete

Is It Safe to Delete ext4.vhdx (Docker)?

Quick Answer: The ext4.vhdx file is a massive virtual hard drive used by Docker and WSL2 on Windows. Deleting it will permanently destroy all your containers and databases.

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:

  1. Docker Desktop will instantly crash and refuse to boot.
  2. Every single Docker image, container, and volume you ever created will be permanently destroyed.
  3. 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:

  1. Open PowerShell as Administrator.
  2. Shut down Docker and WSL: wsl --shutdown
  3. Open the DiskPart tool: diskpart
  4. Select the file: select vdisk file="C:\Users\YourName\AppData\Local\Docker\wsl\data\ext4.vhdx"
  5. Compress it: compact vdisk
  6. 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...

Related in developer

The AI Engineer's Model Disk Cleanup Guide: Hugging Face, Ollama & PyTorch

The ultimate 1,200-word field guide for AI developers and local LLM hobbyists to reclaim 200GB+ from Ollama, Hugging Face, PyTorch, and vLLM model weights.

Safe to Delete

Android Studio System Index Cache (AndroidStudio Cache)

Android Studio caches Gradle project indexes, VFS caches, and compiler artifacts. Invalidate and clear is safe.

Safe to Delete

Ansible Automation Temp & Fact Cache (~/.ansible/tmp)

Ansible stores temporary playbook execution modules and target host fact JSON caches in ~/.ansible/tmp. Clearing Ansible tmp is safe.

Safe to Delete
Back to all files