docker image prune: Remove Unused Images
Remove dangling - or all unused - images to free disk.
docker image prune removes images that are not referenced. This page covers dangling vs all-unused removal and the filters that make it safe in CI.
What it does
By default docker image prune removes only dangling images (untagged layers). With -a it removes every image not used by an existing container, which is a much bigger reclaim.
Common usage
docker image prune -f
docker image prune -af # all unused images
docker image prune -af --filter "until=24h"Common errors in CI
Without -f it prompts and hangs in CI - always pass -f. -af is more aggressive than people expect: it removes any image not currently used by a container, so a base image you will need next step gets deleted and re-pulled. Use --filter "until=" to keep recent images, or scope cleanup to between unrelated jobs.