I'm using Docker for Mac and for saving disk space I want to get rid of some unused local images. As far as I know the local files are stored in ~/Library/Containers/com.docker.docker.
But even if I remove all images and containers from docker the folder keeps it's size of some GB and not a single byte is released. The only option is to remove the com.docker.docker folder completely but this makes only sense if you want to remove all the data and not only the unused images. What am I doing wrong?
sudo docker system prune -af
Just simple put the command given above. It will delete all the image automatically.
What is going on here is that your docker for mac application is really running a virtual machine. That virtual machine has its own disk, which is what that qcow2 file is. That disk gets lazily allocated and won't take up all it space all at once. Once the space is used inside the vm, then the disk will grow on the host.
The disk image will grow until it reaches the size of the disk. Just because a file gets deleted inside the vm, that will not cause the disk image on the host to shrink again.
There is a possible solution to shrink your disk image: https://forums.docker.com/t/where-does-docker-keep-images-containers-so-i-can-better-track-my-disk-usage/8370/7
I have seen a few folks use this trick with some success.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With