DockerJunior

Docker is using too much disk space

Docker never cleans up on its own. Use the prune commands for images, containers, volumes and build cache, and know which one can destroy data.

What you see

  • The disk fills up on a Docker host
  • docker ps -a lists many stopped containers

What it means

The Docker docs say it takes a conservative approach: images, containers, volumes, networks and build cache are generally not removed unless you ask. A stopped container's writable layer still uses disk until the container is removed.

How to confirm the cause

  1. 1
    Show what Docker is using
    docker system df

    Splits usage into images, containers, volumes and build cache.

  2. 2
    List every container, including stopped ones
    docker ps -a

Causes and fixes

  • Dangling and unused images

    HOW TO TELL
    Many old images in docker image ls.
    FIX
    docker image prune removes dangling images only. -a removes every image not used by a container. You can limit by age.
    docker image prune
    docker image prune -a --filter "until=24h"
  • Stopped containers

    HOW TO TELL
    Lots of Exited containers.
    FIX
    Remove stopped containers. Start throwaway ones with --rm next time.
    docker container prune --filter "until=24h"
  • Unused volumes

    HOW TO TELL
    docker volume ls shows volumes no container uses.
    FIX
    Volumes are never removed automatically because that could destroy data. docker volume prune removes only anonymous volumes that no container uses. Named volumes are left alone unless you pass --all, so check before you do.
    docker volume prune
  • Build cache

    HOW TO TELL
    Large build cache in docker system df.
    FIX
    Prune the cache of the current builder.
    docker buildx prune

How to stop it coming back

  • Schedule a prune with an age filter on build and CI hosts.
  • Never prune volumes on a host that holds data you have not backed up.

Keep going

Sources

Docker documentation (docs.docker.com), read 18 Nov 2026 from the official docs repository.

Search

Search cheat sheets and projects