PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteDocker prune is a family of cleanup commands, not one indiscriminate delete operation. Use the command that matches the object you have reviewed: prune stopped containers, dangling images, unused custom networks, volumes, or build cache independently. Start with docker system df, add an age or label filter when appropriate, and treat volume cleanup as a separate data-management decision.
Antihost offers VPS plans with one-click Docker, NVMe storage and a 14-day free trial.
What Docker prune removes
Docker stores several kinds of objects, and each has its own lifecycle. Images provide the filesystem layers used to create containers. Containers can remain after they stop. Networks connect containers, while volumes hold data outside a container’s writable layer. Build systems also retain cache layers to speed up future builds.
As an Amazon Associate I earn from qualifying purchases.
The cleanup commands reflect those differences:
docker image prunetargets images.docker container prunetargets stopped containers.docker volume prunetargets unused volumes.docker network prunetargets unused custom networks.docker builder pruneanddocker buildx prunetarget build cache.docker system prunecombines several cleanup classes, but deliberately leaves volumes out unless you request them.
Docker’s documentation describes this policy as taking “a conservative approach to cleaning up unused objects (often referred to as ‘garbage collection’).” That conservatism matters most for volumes: an unused volume can still contain a database, save files, configuration, or other persistent data.
Inspect before you delete
Run:
docker system df
This gives you a host-specific view of Docker’s disk usage before any deletion. Use it to decide whether the problem is accumulated stopped containers, image layers, volumes, networks, or build cache. Do not interpret the totals as a universal benchmark: Docker’s examples can show values such as 1.84 kB or 13.5 MB because those numbers depend entirely on the host’s contents.
#1 Best Overall
After the inspection, choose the narrowest command that addresses the space you actually need. A build cache problem does not require deleting images, and an old stopped container does not justify touching volumes.
Cleaning up images
Remove only dangling images
By default, the image prune command removes dangling images:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
docker image prune
Dangling images are untagged layers that are no longer associated with a useful image tag. This is the lower-risk image cleanup because it does not broadly remove tagged images that might be useful for a later container start or rebuild.
Remove every image unused by a container
Add -a when you intentionally want to remove images that no container references, including tagged images:
docker image prune -a
A tag alone does not protect an image from this broader operation. Keep a private image that you expect to use again only if a container currently references it, or protect the cleanup with an appropriate review and filter. The trade-off is less disk usage now versus having to pull or rebuild an image later.
Keep recent images
An age filter can retain recent objects while targeting older ones:
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →docker image prune -a --filter "until=24h"
The exact age window is your policy. A 24-hour value means objects newer than that window are excluded from the deletion set; it is not a promise about how much space will be recovered.
Removing stopped containers
Stopped containers are not automatically removed merely because their process exited. They remain until you remove them, unless they were created with the --rm option, which asks Docker to remove the container when it exits.
docker container prune
This command removes stopped containers. If you keep stopped containers for logs, debugging, or a quick restart, inspect them first and use a filter instead of deleting the entire stopped set.
docker container prune --filter "until=24h"
Removing a container is separate from removing its image. A container can be deleted while its image remains available, and image cleanup with -a can later remove that now-unreferenced image.
Pruning volumes without losing persistent data
Why volumes need a separate decision
Volumes can contain persistent application data even when no container is currently attached. For that reason, Docker never removes volumes automatically as part of ordinary cleanup. The default volume command limits itself to unused anonymous volumes:
docker volume prune
“Unused” means no container is using the volume at the time Docker evaluates the command; it does not mean the contents are unimportant. Treat every proposed volume deletion as a data review, not merely a cache cleanup.
Including named volumes
To include named volumes as well as anonymous ones, use:
docker volume prune -a
The -a behavior for volume pruning requires Docker API version 1.42 or newer. Named volumes often carry the deliberate, human-chosen storage for a service, so this is the highest-risk prune scope. Confirm that the data is disposable or backed up before proceeding.
Age-filtered volume cleanup
docker volume prune --filter "until=168h"
An age filter can reduce the chance of deleting a volume created recently during an active migration or test. It does not determine whether the data is valuable; it only narrows the age of candidates.
Removing unused networks
docker network prune removes unused custom networks:
docker network prune
Docker’s system networks—bridge, host, and none—are not pruned. The command therefore cleans up project-created networks that no longer have attached containers without removing those built-in networking choices.
Use an age filter if a network may be temporarily detached during a deployment:
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsdocker network prune --filter "until=24h"
Clearing build cache
Build cache is independent of ordinary image and container cleanup. Use the builder command when cached build layers are the source of disk usage:
docker builder prune
For builds managed through Buildx, use:
docker buildx prune
These commands target build cache rather than stopped containers, networks, or volumes. That separation lets you reclaim compilation layers without changing the runtime objects your services depend on.
What docker system prune does
The system command is a convenience operation that combines several default cleanup classes:
docker system prune
Without extra flags, it removes stopped containers, unused custom networks, dangling images, and unused build cache. It does not remove volumes by default.
Free tools Windows power users keep installed
One-click scans. No signup required.
Use --volumes when you deliberately want the system operation to include unused anonymous volumes:
docker system prune --volumes
Use -a to broaden image cleanup from dangling images to all images not referenced by a container:
docker system prune -a
The broadest form combines both expansions:
docker system prune -a --volumes
This can remove stopped containers, unused custom networks, every image unused by a container, build cache, and unused anonymous volumes. Because it combines a wider image scope with volume deletion, reserve it for a reviewed maintenance window rather than routine housekeeping.
Filters: age windows and labels
The until filter
Prune commands support an until condition. For example:
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →docker container prune --filter "until=24h"
docker image prune -a --filter "until=168h"
Choose a window that matches your rollback needs. A short window is suitable for disposable build debris; a longer window gives an operations team more time to inspect a stopped container or recover a recently created artifact.
Label conditions
Where the specific prune command supports label filtering, labels can target objects or protect them. For example:
Best Value
docker container prune --filter "label!=keep"
This expresses a policy of excluding objects marked with the keep label from the deletion set. Check the command’s help output and your Docker version before relying on a label expression in automation, because filter support is command-specific.
How multiple filters combine
Different filter keys are ANDed: an object must satisfy every different condition. Repeating the same key creates OR behavior among those values. In practical terms, an object selected by both an age rule and a label rule must pass the age condition and the label condition, while repeated label values broaden the acceptable label matches.
Quote filter expressions in shell scripts so the comparison operator and value reach Docker unchanged:
docker image prune -a
--filter "until=168h"
--filter "label!=keep"
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Command comparison
| Goal | Command | Default deletion scope | Important caution or expansion |
|---|---|---|---|
| Remove dangling images | docker image prune |
Dangling images | Use -a to include all images unused by containers. |
| Remove all images unused by containers | docker image prune -a |
Dangling and other unreferenced images | Tagged images you want later can also be removed. |
| Remove stopped containers | docker container prune |
All stopped containers unless filtered | Containers started with --rm are removed automatically on exit. |
| Remove anonymous unused volumes | docker volume prune |
Unused anonymous volumes | Volumes can hold persistent data. |
| Remove named and anonymous unused volumes | docker volume prune -a |
Unused named and anonymous volumes | Requires API 1.42 or newer and carries the greatest data risk. |
| Remove unused custom networks | docker network prune |
Unused custom networks | bridge, host, and none are retained. |
| Remove build cache | docker builder prune |
Builder cache | Use docker buildx prune for Buildx-managed cache. |
| Combined cleanup | docker system prune |
Stopped containers, unused custom networks, dangling images, and build cache | Volumes are excluded unless --volumes is supplied. |
| Broad combined cleanup | docker system prune -a --volumes |
Combined cleanup plus all unused images and unused anonymous volumes | Review every category before running. |
A safe, repeatable prune workflow
- Measure first. Run
docker system dfand identify which object type is consuming space. - List the deletion boundary. Decide whether you need stopped-container cleanup, dangling-image cleanup, cache cleanup, network cleanup, or volume cleanup. Do not start with the broadest command simply because it is shorter.
- Choose a narrow command. Run the matching object-specific prune command. This makes the confirmation prompt and resulting deletions easier to reason about.
- Protect recent work. Add an
untilfilter such as--filter "until=24h"when recent objects must remain available. - Apply labels deliberately. Use a supported label condition such as
label!=keepwhen your object-labeling policy is established and tested. - Review volumes separately. Keep the default system prune volume-free unless you have explicitly checked anonymous volume contents. Use volume
-aonly when named-volume deletion is intentional and the API requirement is met. - Confirm the result. Run
docker system dfagain and verify that the expected category changed without relying on a generic reclaimed-space estimate. - Automate only after testing. Add
--forceonly when you intentionally want to skip the confirmation prompt. A forced command should still use the same narrow scope and filters as an interactive one.
Common mistakes and how to avoid them
Assuming “prune” means volumes are included
They are not included in ordinary docker system prune. If persistent data is the concern, this default is a safety feature, not a missing option.
Using -a without understanding image references
Image -a removes images not referenced by any container, including tagged images. Use it when you can recreate or pull those images, not as a routine replacement for dangling-image cleanup.
Deleting every stopped container during debugging
Stopped containers can preserve a useful failed state for inspection. Apply an age filter or remove only after collecting the logs and details you need.
Treating an unused volume as disposable
Docker’s definition of unused is about attachment, not business value. A detached volume may be the only copy of an application’s persistent files, so volume pruning belongs in a backup and retention policy.
Expecting one command to reclaim a fixed amount
Reclaimed space varies with the host’s images, layers, containers, and cache. The 1.84 kB and 13.5 MB totals shown in Docker examples illustrate command output for particular hosts; they are not general performance or storage guarantees.
Quick Recap
Choosing the right command
- If only untagged image debris has accumulated, use
docker image prune. - If old stopped runs are the problem, use
docker container prune, preferably with an age filter. - If builds are consuming the disk, use
docker builder pruneordocker buildx prune. - If abandoned project networks are cluttering the host, use
docker network prune. - If anonymous volumes are known to be disposable, use
docker volume pruneafter reviewing the data risk. - Use
docker system prunefor a coordinated cleanup of the default non-volume categories, and reservedocker system prune -a --volumesfor a deliberate, fully reviewed reset of unused objects.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




