Docker Image Prune Safely: Dangling Images vs -a
Inspect disk usage and container references before cleaning up Docker images, and understand the default, -a, and creation-time filter scopes.
When reclaiming Docker disk space, docker image prune removes only dangling images by default. Adding -a also targets tagged images that no existing container references. Check the selected Docker environment, stopped containers, and images you may need again before proceeding.
AI-generated illustration of cleaning up unused images
Inspect usage and candidates first
The first command shows the selected context. Cleanup applies to the connected Docker daemon, so check especially carefully with a remote context or Docker Desktop. docker system df reports disk usage for Docker objects. Image layers can be shared, so summing listed sizes may not equal the space actually reclaimed.
The last command lists stopped as well as running containers. Images referenced by a container are excluded from the unused-image scope of -a. Docker pruning guide
Default cleanup versus -a
The default command removes dangling images: images that are untagged and not referenced by a container. Review the scope when prompted before continuing. Inspect the list first; an absent tag alone does not tell you everything you need to know.
With -a, tagged images that no container references are included too. An image named in a Compose file can still be eligible if no container references it. A later deployment may need to pull it again; ensure you have a recovery path for an image built only locally. Command reference
Limit the scope by creation time
This example targets images created more than 168 hours before the daemon's current time that no container references. until uses the image creation time, not its last use. An older image may still be needed later, so identify what to retain first. If a supplied date has no time zone, the daemon's local time zone is used. Filter reference
Verify after cleanup
Check the reclaimed space in the command output and the resulting usage. Shared layers and other references affect the amount actually reclaimed. -f skips the confirmation prompt, so avoid it until you have reviewed the scope and impact. docker image prune cleans up images; it does not prune volumes. Check the separate scope and data implications before using docker system prune or deleting volumes.
This article is based on Docker's official documentation reviewed on November 12, 2026. The commands are illustrative and were not run against a Docker daemon.