# Disk space usage

**URL:** <https://forums.docker.com/t/disk-space-usage/140795>\
**Category:** Docker Desktop\
**Tags:** windows\
**Created:** [April 11, 2024, 12:03pm UTC](https://forums.docker.com/t/disk-space-usage/140795 "2024-04-11T12:03:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![thierryne](https://avatars.discourse-cdn.com/v4/letter/t/c57346/32.png) [@thierryne](https://forums.docker.com/u/thierryne)\
**Post date:** [April 11, 2024, 12:03pm UTC](https://forums.docker.com/t/disk-space-usage/140795/1 "2024-04-11T12:03:22Z")

</div>

I made a docker compose build command and it downloaded half of the internet, filling up my disk. As an emergency measure I pushed Ctrl-C. Then I executed docker system prune to no avail, then Docker Desktop Disk space extension to no avail.

So what I think has happened that since I pushed Ctrl-C in panic, docker compose did not perform any sort of cleanup.

So how to clean up manually and free the disk space? For example, where does Docker cache downloaded files/temporary files?

My use case is Windows 10 + WSL2 + Docker desktop with WSL integration enabled.

---

<div class="post-metadata">

**Author:** ![rimelek](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rimelek/32/41602_2.png) [@rimelek](https://forums.docker.com/u/rimelek)\
**Post date:** [April 12, 2024, 8:23pm UTC](https://forums.docker.com/t/disk-space-usage/140795/2 "2024-04-12T20:23:46Z")

</div>

If the files were downloaded to the container’s filesystem, the image size of Docker Desktop’s WSL2 distribution has already changed. Pruning data in the VM wil not itself decrease the disk size. On some systems like macOS, I heard that decreasing the disk size is possible from the GUI (I never tried), but on Windows, you need to deal with it manually. I think @meyay somewhere already answered it, but I couldn’t find yet.

What I found now is this:

> **[Optimize-VHD (Hyper-V)](https://learn.microsoft.com/en-us/powershell/module/hyper-v/optimize-vhd?view=windowsserver2022-ps)**
>
> Use this topic to help manage Windows and Windows Server technologies with Windows PowerShell.

You would need to find where the vhdx is. From powershell it should be here:

```auto
$env:USERPROFILE\AppData\Local\Docker\wsl\data\ext4.vhdx

```

If you have Windows home, you will probably need this:

[https://answers.microsoft.com/en-us/windows/forum/all/optimize-vhd-not-found-in-windows-10-home/a727b760-0f82-4d0f-8480-d49eeaeb11a2](https://answers.microsoft.com/en-us/windows/forum/all/optimize-vhd-not-found-in-windows-10-home/a727b760-0f82-4d0f-8480-d49eeaeb11a2)

Assuming you have pro, after you stopped docker desktop, it could work:

```auto
Optimize-VHD -Path "$env:USERPROFILE\AppData\Local\Docker\wsl\data\ext4.vhdx" -Mode Full

```

Note that iI don’t know how stable this operation is. If you can and need, make a backup of data in case you are afraid of losing data in Docker Desktop.

---

<div class="post-metadata">

**Author:** ![meyay](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/meyay/32/34000_2.png) [@meyay](https://forums.docker.com/u/meyay)\
**Post date:** [April 12, 2024, 10:25pm UTC](https://forums.docker.com/t/disk-space-usage/140795/3 "2024-04-12T22:25:55Z")

</div>

`diskpart` can be used on all Windows 10/11 version to `compact` the vhdx file:

> **[How to Shrink a WSL2 Virtual Disk – Stephen Rees-Carter](https://stephenreescarter.net/how-to-shrink-a-wsl2-virtual-disk/)**
>
> You can use the diskpart tool to compact a VHDX. This allows you to shrink a WSL2 virtual disk file, reclaiming disk space. I went from 100GB to 15GB.

---

<div class="post-metadata">

**Author:** ![thierryne](https://avatars.discourse-cdn.com/v4/letter/t/c57346/32.png) [@thierryne](https://forums.docker.com/u/thierryne)\
**Post date:** [April 13, 2024, 10:34am UTC](https://forums.docker.com/t/disk-space-usage/140795/4 "2024-04-13T10:34:02Z")

</div>

Thanks, this worked!
