Quick Summary: Docker Desktop eating disk space
Docker Desktop keeps every image, container, volume, log and build layer inside one virtual disk file: docker_data.vhdx on Windows and Docker.raw on Mac. That file grows as you work, but on Windows it never shrinks on its own. The fix is a two-step job: first prune what you no longer need, then compact (Windows) or resize (Mac) the virtual disk so the freed space actually returns to your drive.
Table of Contents
Why Your Drive Suddenly Feels Full
You installed Docker to run a database or a small dev stack. A few months later, your C: drive or Mac SSD is in the red, and you cannot work out where 60, 100 or even 300 GB went. If that sounds familiar, you are dealing with Docker Desktop eating disk space, one of the most common complaints on the Docker forums.
The frustrating part is that the usual advice only gets you halfway. Running docker system prune deletes data inside Docker, yet Windows often shows exactly the same free space afterwards. On a Mac, Finder may even report a 64 GB file that is mostly empty. Both behaviours are normal, and both have a fix.
In this guide, we will explain why it happens, show you exactly where the data lives, and walk through nine methods in order, from the safest clean-up to a full reset. Along the way, we will also cover the hidden causes that most competing guides leave out.
Why Docker Desktop Uses So Much Space
Docker containers need a Linux kernel. Since Windows and macOS do not have one, Docker Desktop runs a small Linux virtual machine in the background. Everything Docker stores lives on that VM’s virtual hard disk. As a result, Docker Desktop eating disk space is really a virtual disk that keeps growing. Here is what fills it.
1. The virtual disk only grows
On Windows with the WSL 2 backend, the VHDX file expands whenever Docker writes data. However, when you delete images or containers, the space is freed inside Linux but the file on Windows stays the same size. One developer on DEV Community found two Docker VHDX files using more than 500 GB, while the real active data was only around 30 to 35 GB.
Key point: deleting Docker data frees space inside the virtual disk, not on your actual drive. You must compact the file to get the space back on Windows.
2. Images and layers pile up
Every docker pull and every rebuild adds layers. Old tags, dangling <none> images and multiple versions of the same base image add up quickly, especially with large images such as CUDA, Python data-science stacks or SQL Server.
3. Build cache
BuildKit saves intermediate layers so later builds are faster. On an active project, this cache can quietly reach tens of gigabytes, and many people never look at it.
4. Volumes and logs
Databases write to volumes, and those volumes outlive the containers that created them. On top of that, container logs use the json-file driver by default with no size limit, so a chatty container can write gigabytes of logs.
Where Docker Desktop Stores Its Data
Before cleaning anything, it helps to know which file is actually growing. The paths below are the defaults; your location will differ if you changed the disk image location in Settings.
| Platform / version | Default file location |
|---|---|
| Windows, Docker Desktop 4.30 and newer (WSL 2) | %LOCALAPPDATA%\Docker\wsl\disk\docker_data.vhdx |
| Windows, Docker Desktop system distro | %LOCALAPPDATA%\Docker\wsl\main\ext4.vhdx (small, usually under 1 GB) |
| Windows, older installs (before 4.30) | %LOCALAPPDATA%\Docker\wsl\data\ext4.vhdx (the old docker-desktop-data distro) |
| macOS (Apple silicon and Intel) | ~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw |
| Linux (Docker Desktop) | ~/.docker/desktop/vms/0/data/Docker.raw |
Starting with Docker Desktop 4.30, the separate docker-desktop-data WSL distro was retired; data now sits on a separate data disk that is mounted into the docker-desktop distro. That is why many older tutorials point you to a folder that no longer exists.
Before You Delete Anything
When you fix Docker Desktop eating disk space, some of the methods below permanently remove data. Therefore, take two minutes to protect anything you care about:
- Back up databases stored in named volumes, for example with
docker run --rm -v myvolume:/data -v %cd%:/backup alpine tar czf /backup/myvolume.tgz /data. - Push custom images you built locally to a registry, or note the Dockerfile so you can rebuild them.
- Check free space on the host. Compacting a VHDX needs some working room, so clear a few gigabytes first if the drive is completely full.
If your Windows drive is also crowded by other folders, our guides on AppData Local taking up too much space and deleting the Windows.old folder safely can free room quickly.
How to Fix Docker Desktop Eating Disk Space
Work through these methods in order. The first five clean data inside Docker, which is safe and reversible in the sense that images can be pulled again. Methods 6 and 7 hand the freed space back to your operating system. The last two are for stubborn cases.
Method 1: Check What Is Using Space
Do not guess. Docker can tell you exactly where the space goes. Open a terminal (PowerShell, Command Prompt or Terminal on Mac) while Docker Desktop is running and enter:
docker system dfYou will see four rows: Images, Containers, Local Volumes and Build Cache, each with a RECLAIMABLE column. That column is the space you can recover without touching anything in use. For a per-item breakdown, add the verbose flag:
docker system df -vNext, compare that total with the size of the virtual disk file from the table above. If Docker reports 20 GB but the file is 120 GB, most of your problem is unreclaimed space, and you should jump to Method 6 or 7 after cleaning.
Method 2: Remove Unused Containers and Images
Stopped containers and unused images are usually the biggest easy win when Docker Desktop is eating disk space. Run these one at a time so you understand what each removes:
- Remove all stopped containers:
docker container prune - Remove dangling images (the untagged
<none>ones):docker image prune - Remove every image not used by at least one container:
docker image prune -a - Type y when Docker asks you to confirm, then check the “Total reclaimed space” line.
Alternatively, you can do it all in one go:
docker system prune -aNote:
docker system prune -aremoves stopped containers, unused networks, all unused images and the build cache. It does not touch volumes unless you add--volumes.
If you prefer clicking, open the Docker Desktop Dashboard, go to Images, filter by Unused, select them and click Delete. The Containers tab works the same way.
Method 3: Clear the Build Cache
If you build images often, the build cache is frequently the hidden reason behind Docker Desktop eating disk space. Clear it with:
docker builder prune -aTo keep recent cache entries for faster builds, remove only older ones instead:
docker builder prune --filter "until=72h"For multi-builder setups using buildx, run docker buildx ls first, then docker buildx prune -a for each builder you no longer need.
Method 4: Clean Up Unused Volumes
Volumes hold real data, so be careful here, even if Docker Desktop eating disk space is pushing you to delete everything. First, list them and see which ones are unused:
docker volume ls -f dangling=trueHere is a detail many guides get wrong. Since Docker API 1.42, docker volume prune removes only anonymous volumes by default. Named volumes, such as postgres_data, are left alone unless you add the -a flag:
docker volume prune -aUse this only after backing up anything important. Alternatively, delete specific volumes by name with docker volume rm volume_name.
Method 5: Cap Runaway Container Logs
By default, Docker writes container output to JSON log files with no size limit. A container stuck in a restart loop or printing debug output can fill gigabytes in a day. To set a limit for all new containers:
- Open Docker Desktop and click the Settings (gear) icon.
- Select Docker Engine in the left menu.
- Add the log options shown below inside the existing JSON, keeping the commas valid.
- Click Apply & restart.
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
}
}This keeps each container at a maximum of about 30 MB of logs. Keep in mind that the setting applies only to containers created afterwards, so recreate existing ones (for example with docker compose up -d --force-recreate) to apply it.
Method 6: Compact the VHDX on Windows
This is the step that actually gives space back to Windows, and it is the answer most people are missing when Docker Desktop keeps eating disk space after a prune. Always prune first (Methods 2 to 4), because compacting only removes empty blocks.
Step 1: Shut everything down. Right-click the Docker whale in the system tray and choose Quit Docker Desktop. Then open PowerShell as Administrator and run:
wsl --shutdownWait about 10 seconds. If the VHDX is still in use, compacting will fail with a “being used by another process” error.
Step 2a (Windows Pro, Enterprise, Education): use Optimize-VHD. This needs the Hyper-V PowerShell module. Run:
Optimize-VHD -Path "$env:LOCALAPPDATA\Docker\wsl\disk\docker_data.vhdx" -Mode FullStep 2b (Windows Home): use DiskPart. Optimize-VHD is not available on Home editions, but DiskPart works everywhere. Type diskpart, press Enter, then run these lines one by one, replacing YourName with your Windows user folder:
select vdisk file="C:\Users\YourName\AppData\Local\Docker\wsl\disk\docker_data.vhdx"
attach vdisk readonly
compact vdisk
detach vdisk
exitStep 3: Check the result. Open the folder in File Explorer and compare the file size. Then restart Docker Desktop. If you are on an older install, repeat the steps for wsl\data\ext4.vhdx as well.
Compacting is safe for your data because it only removes unused blocks. Still, never compact while Docker or WSL is running.
Method 7: Shrink Docker.raw on Mac
On macOS, Docker.raw is a sparse file. Finder and ls -lh show its maximum size (often 64 GB), not what it really uses. So first check the true size in Terminal:
du -h ~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.rawAccording to Docker’s own Mac FAQ, after you prune, space held by a Docker.raw file is returned to the host within a few seconds. If the real size is still too large, lower the cap:
- Open Settings in Docker Desktop.
- Go to Resources and then Advanced.
- Move the Virtual disk limit slider down to a sensible value, such as 32 to 64 GB.
- Click Apply & restart and accept the warning.
Warning: reducing the disk limit deletes the current disk image, so every image, container and volume is lost. Back up first.
Method 8: Move the Disk Image to Another Drive
Sometimes you genuinely need a lot of images, and Docker Desktop eating disk space on a small SSD is simply a capacity problem. In that case, move Docker’s storage off the system drive instead of fighting it:
- Open Settings > Resources > Advanced.
- Find Disk image location and click Browse.
- Pick a folder on a larger drive, such as
D:\DockerData. - Click Apply & restart and wait while Docker moves the files.
Use this built-in option instead of dragging the file in File Explorer or Finder, because Docker Desktop would otherwise lose track of it.
Method 9: Clean, Purge or Reset Docker Desktop
If nothing else works and you still see Docker Desktop eating disk space, start fresh. Click the Troubleshoot (bug) icon at the top of the Docker Desktop Dashboard. You will see two relevant options:
- Clean / Purge data deletes all images, containers and volumes but keeps your settings.
- Reset to factory defaults wipes data and settings, creating a brand-new, small virtual disk.
After a reset, pull only what your current projects need, for example with docker compose pull inside each project folder.
Updating also matters. Several disk issues, including a Mac bug where a lowered disk limit was ignored under Docker VMM, were fixed in later releases (version 4.42).
An Easier Way to Find What Is Eating Space
The manual methods for Docker Desktop eating disk space work, but they assume you already know Docker is the culprit. In reality, a full C: drive is usually several things at once: Docker’s VHDX, browser caches, old installers and forgotten downloads. If you would rather see everything in one view first, Oualator Storage Doctor is a free Windows 10 and 11 app that scans your drives, flags large app storage such as Docker, and explains the risk level of each item before you remove anything. Nothing is deleted without your confirmation, which makes it a safe starting point before you run the commands above.
Hidden Causes Most Guides Miss
After going through the top-ranking articles, we noticed that most stop at docker system prune. However, several less obvious causes keep Docker Desktop eating disk space even after a careful clean-up:
- Space lost after updates. Users on Docker Desktop 4.7x have reported the data VHDX growing by roughly 1.5 GB after each update, linked to stale
isocachefiles that prune cannot see. Compacting (Method 6) and keeping Docker updated are the current workarounds. - Reading the wrong number. On Mac and Linux, Finder and
lsreport the sparse file’s maximum size. Always usedu -hbefore assuming there is a problem. - Named volumes survive prune. As covered in Method 4, modern Docker skips named volumes unless you pass
-a, so old database volumes linger for months. - Two VHDX files on older installs. Upgraded systems may still carry a legacy
docker_data.vhdxfrom the old distro alongside the new one. Check both folders under%LOCALAPPDATA%\Docker\wsl. - Your own WSL distros. If you also run Ubuntu in WSL, its
ext4.vhdxgrows the same way and is often mistaken for Docker. Compact it with the same steps. - Sparse VHD is restricted. Newer WSL versions block
wsl --manage docker-desktop --set-sparse trueunless you add an unsafe flag, so manual compacting is still the reliable route.
How to Stop It From Happening Again
Cleaning once is good, but a few habits will stop Docker Desktop eating disk space in the first place:
- Run containers with
--rmfor one-off tasks so they delete themselves on exit. - Use slim base images such as
alpineor-slimvariants, and use multi-stage builds so build tools never reach the final image. - Add a
.dockerignorefile to keepnode_modules,.gitand large data out of the build context. - Schedule a weekly prune, for example
docker system prune -f --filter "until=168h", using Task Scheduler or cron. - Compact the VHDX monthly on Windows if you build images heavily.
- Keep log limits in place as shown in Method 5.
It also helps to stop Docker Desktop from launching with Windows if you only use it occasionally. Our guide on stopping applications from opening on startup shows how. Similarly, if your drive is under pressure from other caches, see how to clear the NVIDIA shader cache, where to find the Chrome cache and why the WindowsApps folder takes up space.
Frequently Asked Questions
Why does Docker not free up space after I delete images?
Because the data lives inside a virtual disk. Deleting images frees space inside that disk, but the VHDX file on Windows does not shrink by itself. You need to compact it with Optimize-VHD or DiskPart.
Is it safe to delete docker_data.vhdx?
Only if you are happy to lose every image, container and volume. Docker Desktop will create a new, empty disk the next time it starts. A safer option is to use Clean / Purge data from the Troubleshoot menu.
How much space should Docker Desktop use?
The application itself needs only a few gigabytes. Everything else depends on your images. For typical web development, 10 to 30 GB is common, while machine-learning images can easily push it past 100 GB. To estimate other files on your drive, our storage size guide is a handy reference.
Does docker system prune delete my volumes?
No, not by default. You must add --volumes, and even then only anonymous volumes are removed on current Docker versions.
Will reinstalling stop Docker Desktop eating disk space?
Not on its own. Uninstalling may leave the old VHDX or Docker.raw behind, and the problem returns as soon as images build up again. Pruning, compacting and log limits are the long-term fix.
Can I limit how big Docker Desktop’s disk can get?
Yes. On Mac, use the Virtual disk limit slider under Settings > Resources > Advanced. On Windows with WSL 2, the size is managed by WSL, so regular pruning and compacting are the practical way to keep it in check.
Final Thoughts
Docker Desktop eating disk space is rarely a bug. In most cases, it is the expected result of a virtual disk that grows easily but shrinks only when you ask it to. Start with docker system df, prune images, build cache and volumes you no longer need, and then compact the VHDX on Windows or resize Docker.raw on Mac.
Finally, put limits and habits in place to prevent Docker Desktop eating disk space again, so you do not end up here next month. With log caps, a weekly prune and an occasional compact, Docker stays useful without slowly swallowing your drive.