docker system prune removes stopped containers, unused networks, dangling images, and dangling build cache. With -a it also removes all unused (not just dangling) images, and --volumes adds anonymous volumes. It is the go-to fix for "no space left on device".
Common flags
-a, --all - remove all unused images, not only dangling ones
-f, --force - do not prompt for confirmation
--volumes - also remove unused anonymous volumes
--filter - limit by condition, e.g. until=24h
Example
shell
docker system prune -af
docker system prune -af --volumes --filter "until=24h"
In CI
Run docker system prune -af when a build fails with "no space left on device" on a long-lived runner, or proactively at job start. Be careful with -a: it removes images not used by a running container, including ones you may rely on for the next step. Ephemeral runners rarely need this since the disk is discarded after the job.
Key takeaways
-af force-removes all unused images plus stopped containers, networks, and dangling cache.
--volumes additionally clears anonymous volumes.
It is the standard remedy for "no space left on device" on persistent runners.
Frequently asked questions
docker system prune Command Reference?
docker system prune removes stopped containers, unused networks, dangling images, and dangling build cache. With -a it also removes all unused (not just dangling) images, and --volumes adds anonymous volumes. It is the go-to fix for "no space left on device".
In CI?
Run docker system prune -af when a build fails with "no space left on device" on a long-lived runner, or proactively at job start. Be careful with -a: it removes images not used by a running container, including ones you may rely on for the next step. Ephemeral runners rarely need this since the disk is discarded after the job.