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 -alists 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
- 1Show what Docker is using
docker system df
Splits usage into images, containers, volumes and build cache.
- 2List 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 pruneremoves dangling images only.-aremoves 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
Exitedcontainers. - FIX
- Remove stopped containers. Start throwaway ones with
--rmnext time.docker container prune --filter "until=24h"
Unused volumes
- HOW TO TELL
docker volume lsshows volumes no container uses.- FIX
- Volumes are never removed automatically because that could destroy data.
docker volume pruneremoves 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
- Runbook: No space left on device
- Cheat sheet: Docker
- Lesson: the containers topic in Learn
Sources
Docker documentation (docs.docker.com), read 18 Nov 2026 from the official docs repository.