I often run into disk space issues when building docker images (like JS errors "ENOSPC: no space left on device
). I am used to run docker system prune
to clear up some space, but it was a bit too often to my liking and I realised maybe something was not working as expected
After running a docker system prune
I have the following docker system df
output
> docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 102 0 41.95GB 41.95GB (100%)
Containers 0 0 0B 0B
Local Volumes 53 0 5.254GB 5.254GB (100%)
Build Cache 383 0 0B 0B
It seems like there are still 42GB disk space used by images (or does this refer to some sort of "reserved space" for docker ? Anyways if those 42GB are held up somehow, it could very much explain why my disk is getting so full so often
I am on macOS and with the above docker system df
, when I open my docker app > Resources I see
Disk image size: 120 GB (81.3 GB used)
Am I missing something ?
As @Oo.oO mentioned in his comment you probably have images that arent considered "dangling" but you still don't use them for anything or have a container using them, as noted in this answer explaining the difference between dangling image and an unused one is that a dangling image is plainly put a previous version of the same image that's now will probably show as:
<none> <none>
while an unused image is just that, unused which doesn't fall under the "dangling" classification and that's why your images arent being deleted. that's when running the following command will solve the issue:
docker system prune -a
as noted in the help menu for the command
-a, --all Remove all unused images not just dangling ones
Though if you want only to delete unused images (as this is your main use case) you can use the following command instead:
docker images prune -a