LESSON · 1 OF 5

Seeing what Docker uses

Seeing what Docker uses

Docker accumulates things. Every image you pull, container you run, and volume you create takes disk, and over weeks it adds up until a build fails with "no space left on device". The first step in staying ahead of that is seeing what is actually there.

docker system df

bash
docker system df

This is Docker's disk-usage summary. It breaks down space by category - images, containers, local volumes, and build cache - showing the total size of each and, crucially, how much is reclaimable:

text
TYPE            TOTAL   ACTIVE   SIZE      RECLAIMABLE
Images          12      3        4.2GB     3.1GB
Containers      8       2        120MB     90MB
Local Volumes   5       2        800MB     600MB
Build Cache     40      0        1.5GB     1.5GB

The RECLAIMABLE column is the one to read - it is space you could free right now without touching anything in use. A big reclaimable number means a prune is overdue.

Where the space goes

Four culprits, in rough order of how often they surprise people:

  • Stopped containers you ran and never removed, each holding its writable layer.
  • Dangling images - untagged layers left behind by rebuilds.
  • Unused volumes - data from containers you removed but whose volumes remained.
  • Build cache - layers from every build, which grows fast on a machine that builds often.

On this machine

This microVM has an 8 GB disk. It is easy to fill with a few large images and a pile of stopped containers, and a full disk breaks builds and pulls. Running docker system df now and then, and pruning when the reclaimable number grows, keeps it healthy. The next node is the cleanup itself.

Commands this node introduces

  • docker system df - summarise Docker's disk use and what is reclaimable
Spin up a fresh environment and practice live.
docker · fresh machine · ready in under a minute