Reclaim disk space from Docker

Docker can silently use 20+ GB. Measure, then clean in order from safest to most aggressive.

2 min4 stepsmacOS · Linux · Windows

  1. Measure

    The RECLAIMABLE column is what you can free.

    docker system df
    TYPE            TOTAL   ACTIVE   SIZE      RECLAIMABLE
    Images          23      4        9.8GB     7.1GB (72%)
    Build Cache     188     0        3.2GB     3.2GB
  2. Remove stopped containers

    Safe if you don’t need their filesystem state.

    docker container prune
  3. Remove dangling images

    Leftover layers from old builds.

    docker image prune
  4. Go all in

    Removes every image not in use and the build cache. Volumes (data) are kept.

    docker system prune -a

    You’ll need to re-download or rebuild images. Volumes are kept unless you add --volumes.

More guides