docker system df before docker system prune

A development machine accumulates dangling layers, stopped containers and orphaned volumes, and none of it is visible until the disk fills.

$ docker system df
TYPE            TOTAL  ACTIVE  SIZE     RECLAIMABLE
Images          84     6       41.2GB   36.8GB (89%)
Containers      31     3       1.1GB    980MB (86%)
Local Volumes   19     4       8.4GB    6.2GB (73%)

$ docker image prune --filter 'until=168h'    # the weekly one
$ docker system prune -a --volumes            # the nuclear one

-a --volumes deletes the database volume of any stack that is not currently running, which is a bad afternoon if that was the only copy of a client’s data. The time-filtered image prune is what belongs in a weekly cron: it removes what has genuinely been abandoned and leaves anything recent. Running system df first takes two seconds and answers whether the prune is worth doing at all.