4

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 ?

Noam Yizraeli
  • 4,446
  • 18
  • 35
Cyril Duchon-Doris
  • 12,964
  • 9
  • 77
  • 164
  • 1
    I am also on `macOS` and what I use is: `docker system prune -a` to remove things completely (all the images, not only dangling ones). Also, I was fed up with missing space and moved all the Docker stuff to external drive. Also, remember that time machine (by default) will backup your Docker stuff. It's a good idea to do something like this: https://www.owsiak.org/macos-time-machine-and-docker/ – Oo.oO Sep 09 '21 at 11:28

1 Answers1

6

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

Noam Yizraeli
  • 4,446
  • 18
  • 35
  • 1
    I just ran `docker images prune -a` but it did nothing and it sill showed "Images | Total = 109 | active = 0 | size = 41GB | RECLAIMABLE = 41GB" However, `docker system prune -a` did remove everything (it took more 10 minutes though). I think I should have added the `--filter "until=24h"` as suggested in the link you gave to keep some of them, but at least I've reclaimed a lot of space, thanks ! – Cyril Duchon-Doris Sep 09 '21 at 15:24
  • Oh, I see... I'm glad you saw it through but that's weird cause it works on my machine, can you send `docker version` output? – Noam Yizraeli Sep 09 '21 at 15:36
  • BTW - I have noticed that removing Docker images using `system prune` can sometimes take ages. This is why I quite often use something like this: https://www.owsiak.org/cleaning-docker-images/ - I stop everything, remove containers and then, images. Sometimes it is way faster. I don't know what is the source of the issue with `prune` though :) – Oo.oO Sep 09 '21 at 18:49