How can I track down excessive disk space usage in Docker on Windows?

0
17
Asked By CuriousCat42 On

Hey everyone, I'm still new to Docker and using it on Windows. I've noticed that the disk usage has shot up to 169 GB over the past month, even though I haven't installed anything new. I have three containers running, all set up about a month ago. When I check the disk space with the command 'docker ps --size', it shows just about 1.5 GB combined, and 'docker system df -v' shows around 1.8 GB. This doesn't match the 169 GB that's reported. I've run the prune commands, but it didn't clear much. How can I find out what's taking up all that space and free it up?

3 Answers

Answered By DockerDiva On

You might want to check for any stopped containers with 'docker container ls -a' and see if there are unused volumes with 'docker volume ls'. Running 'docker system prune -a' can help remove unused images and containers, but proceed with caution as it can delete more than you expect!

CuriousCat42 -

I did run all the prune commands, but unfortunately, they didn't really clean up anything significant. The only image I had was 'hello_world' that wasn't in use.

Answered By LogWatcher On

While it might not be the direct issue, it's worth looking into the log files from your long-running containers. Sometimes those can accumulate and take up a ton of space without you realizing. I've dealt with systems that built up hundreds of gigs of logs before I cleaned them out. You can check the Docker documentation about configuring the default logging driver for more details.

Answered By TechieTom On

On Windows, Docker Desktop uses a WSL2 virtual disk, specifically ext4.vhdx, which grows as needed but doesn't shrink automatically. This explains why there's such a big discrepancy in the disk usage. To check the size of this disk, you can find it at %LOCALAPPDATA%Dockerwsldataext4.vhdx. If it's significantly large, that's likely where your missing space is. To shrink it, quit Docker Desktop, open an elevated PowerShell and run 'wsl --shutdown'. Then, execute 'Optimize-VHD -Mode Full -Path "$env:LOCALAPPDATADockerwsldataext4.vhdx"'. This should help reclaim some space. Let me know if you want assistance with checking for overlay2 or volume issues!

NewbieDude -

I tried the optimization, but it only went up to 13% after a long wait. The disk size hasn’t changed at all! Any other suggestions?

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.