docker system prune, and the disk it gives back

A development machine that builds images daily 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 system prune -a --volumes
# and the safer daily version:
$ docker image prune --filter 'until=168h'

-a --volumes is the nuclear option and will delete 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 tells you whether the prune is worth doing at all.