Docker prune commands delete objects that Docker considers unused, but each command has a different scope. A routine cleanup normally starts with docker system df, then removes only the object type you have reviewed. Use docker container prune for stopped containers, docker image prune for unused images, docker network prune for unattached custom networks, and docker builder prune for build cache. Treat volumes separately: Docker leaves them out of normal system cleanup because they can contain persistent application data.
Antihost offers VPS plans with one-click Docker, NVMe storage and a 14-day free trial.
What Docker prune removes
Docker stores more than running containers. Image layers, stopped containers, custom networks, volumes and build cache can all consume disk space. “Pruning” is Docker’s garbage-collection process for objects that are no longer in use. Docker describes its approach as conservative because deleting an object can make a later rebuild, rollback or data recovery harder.
As an Amazon Associate I earn from qualifying purchases.
The command you choose determines both the object type and the default deletion rule:
| Goal | Command | Default scope | Main caution |
|---|---|---|---|
| Remove dangling images | docker image prune |
Unreferenced image layers normally shown as dangling | Use -a only after checking which tagged images are no longer needed |
| Remove stopped containers | docker container prune |
All stopped containers unless filtered | Container-writable files and logs disappear with the container |
| Remove unused anonymous volumes | docker volume prune |
Unused anonymous volumes by default | A volume can contain database or upload data even when no container is attached |
| Remove named and anonymous volumes | docker volume prune -a |
All unused volumes; available with API 1.42 and later | Highest data-loss risk |
| Remove unused custom networks | docker network prune |
Custom networks with no attached containers | System networks are retained |
| Remove build cache | docker builder prune or docker buildx prune |
BuildKit or builder cache | Future builds may need to download and rebuild layers |
| Run a combined cleanup | docker system prune |
Stopped containers, unused custom networks, dangling images and unused build cache | Volumes are excluded unless you explicitly request them |
Inspect disk use before deleting anything
Run this first:
docker system df
The report separates images, containers and local volumes and shows reclaimable space. It is a point-in-time view of your host, not a promise of a particular saving. Docker’s examples include totals such as 1.84 kB or 13.5 MB, but those figures are illustrative command output from a particular host, not general performance benchmarks.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
For an object-by-object review, list the resources that could be affected:
docker ps -alists running and stopped containers.docker imageslists local images and tags.docker volume lslists volumes; inspect a candidate withdocker volume inspect NAME.docker network lslists networks; inspect attachments withdocker network inspect NAME.docker builder dureports builder-cache usage when supported by your Docker installation.
Check whether a stopped container is being kept for logs, forensic inspection, a rollback, or a convenient restart. Check volume names against your Compose files, deployment manifests and backup inventory before treating them as disposable.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Prune images without removing useful layers
Remove dangling images only
The narrow image cleanup is:
docker image prune
By default, this targets dangling images: layers no longer associated with a usable repository tag. Docker asks for confirmation. Add --force (or -f) only when you have deliberately accepted the displayed scope:
docker image prune --force
Remove every image unused by a container
docker image prune -a expands the operation beyond dangling layers. It can remove tagged images that no container currently references. That saves more space but eliminates a local copy you may want for an offline restart or rollback. A later docker run or deployment can pull the image again, provided the registry and tag still exist.
Keep recent images or target labels
Use an age filter when a recent rollback window matters:
docker image prune -a --filter "until=168h"
This asks Docker to consider images older than 168 hours (seven days), while retaining newer candidates. Filters can also select labels. For example, where label filtering is supported by the command, --filter "label!=keep" excludes objects carrying the keep label. Apply labels consistently when creating images or containers; a protection rule cannot save an object that was never labelled.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Remove stopped containers deliberately
A container that exits remains on disk unless it was created with --rm. This persistence is useful for reading exit status, logs and filesystem changes, but it also means repeated jobs can accumulate.
To delete stopped containers:
docker container prune
Limit the operation by age when recent failures need investigation:
docker container prune --filter "until=24h"
After Docker displays the candidates, confirm that no automation, operator or monitoring system expects those container names or logs to remain. A pruned container cannot be started again; recreate it from its image and configuration instead.
For one-shot jobs that should never remain after a successful run, create them with docker run --rm. That setting affects the container lifecycle only. It does not automatically remove the image, named volumes or networks used by the job.
Handle volumes as persistent data
Why volumes are excluded from normal system prune
Volumes often hold database files, user uploads, certificates or other state that exists independently of a container. A container can be deleted and recreated while the volume remains attached to the replacement. Because that data may be irreplaceable, docker system prune does not remove volumes by default.
Remove unused anonymous volumes
The default volume cleanup is:
docker volume prune
It targets unused anonymous volumes. “Unused” means that no container is currently using the volume; it does not mean that the contents are unimportant. Inspect each candidate and verify backups before confirming.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Include named volumes only with an explicit review
docker volume prune -a includes unused named volumes as well as anonymous volumes on Docker API 1.42 and later. Named volumes are commonly declared in Compose or deployment files, so an apparently detached volume may be intended for the next deployment. Export or back up data first, then remove only names that are absent from your current and rollback configurations.
Use a label policy if your workflow supports it. For example, mark a production data volume with a retention label and filter out that label during cleanup. Repeatedly test the policy on a non-production host; a typo in a label or filter can change the candidate set.
Free tools Windows power users keep installed
One-click scans. No signup required.
Clean unused networks
Remove custom networks with no attached containers by running:
docker network prune
Docker does not prune the built-in bridge, host and none networks. Custom networks can still encode service-discovery names, IPAM settings or security boundaries in your deployment files. If a stopped container is the only reason a network remains, removing the container first may make the network eligible; otherwise keep the network until its configuration is no longer needed.
Reclaim build cache separately
Build cache is distinct from runtime images. It stores intermediate layers so repeated builds can be faster. Clean it with:
docker builder prune
When you use a Buildx builder, use:
docker buildx prune
These commands affect cache, not your running containers or application volumes. An aggressive cache cleanup can increase build time and network traffic on the next build, so retain cache on frequently used development hosts and prune more aggressively on space-constrained CI workers.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Understand docker system prune
The combined command is:
docker system prune
Without extra options, it removes stopped containers, unused custom networks, dangling images and unused build cache. It does not remove volumes. The confirmation prompt lists the categories Docker intends to process.
Add -a when you intentionally want image cleanup to include every image not referenced by a container:
docker system prune -a
Add --volumes when you also want unused anonymous volumes considered:
docker system prune --volumes
Combining both produces a broad operation:
docker system prune -a --volumes
Reserve that command for a reviewed maintenance window. It broadens image removal and includes unused anonymous volumes; it is not a harmless equivalent of deleting temporary files. If named volumes must be removed, review them with docker volume ls and use the API-appropriate volume command separately.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC 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 & 11Use filters to make cleanup predictable
Age filters
Prune commands accept an until filter, such as:
docker container prune --filter "until=72h"
Choose an interval that covers your investigation and rollback needs. A 24-hour policy may suit disposable CI containers; a production host may require several days or a longer release-retention period.
Label filters
Labels let you express retention policy in the object itself. A protection rule can look like:
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
docker image prune -a --filter "label!=keep"
Use the exact label key and value your tooling creates, and confirm that the specific prune command supports label filters. Labels are not a backup: they protect only against a matching cleanup operation and do not preserve data if someone explicitly removes the object.
Combining filters
Different filter keys are combined with AND logic. An object must satisfy every different condition. Repeating the same key supplies OR alternatives. Thus, an until condition combined with a label condition narrows candidates to objects meeting both rules, while two values for the same key broaden that key’s matches. Test complicated filters on a disposable host before putting them in automation.
Recommended Free Tools
A safe, repeatable cleanup workflow
- Measure. Run
docker system dfand record which category is consuming space. - Inventory dependencies. Check containers, image tags, volume names, network attachments and builder configuration.
- Choose one object type. Start with the narrow command that addresses the measured problem rather than using system-wide cleanup.
- Set a retention boundary. Add an
untilfilter and label exclusions when recent or protected objects must remain. - Read the confirmation list. Stop if a candidate is part of an active deployment, rollback plan or data store.
- Run without
--forcefirst. Keep the prompt during manual maintenance. Use--forceonly in a reviewed, repeatable job where the scope is already constrained. - Verify service health. Check that expected containers can restart, images can be pulled, networks reconnect and applications can read their volumes.
- Document the policy. Record the age threshold, labels, Docker API requirements and backup checks so the next operator knows why an object is safe to remove.
Common mistakes and recovery options
“I pruned an image that I still need.”
If the image exists in a registry, pull the same immutable digest or tag again. If it existed only locally and was not backed up, its layers may not be recoverable. Keep release images in a registry and use digests for rollback rather than relying on an untracked local cache.
“A stopped container disappeared.”
Recreate it from the original image, environment variables, mounts and network settings. Data stored only in the container’s writable layer is gone; data in a separate volume remains if that volume was not pruned.
“A volume cleanup removed application data.”
Stop further cleanup, identify the volume name and restore from the latest verified backup or snapshot. Docker’s prune command does not provide a recycle bin. This is why volume backups and a tested restore procedure are prerequisites for aggressive maintenance.
“The disk is still full after pruning.”
Re-run docker system df. The remaining usage may be active images, running containers, attached volumes, build cache belonging to another builder, container logs or files outside Docker’s managed store. Pruning cannot remove objects that are still referenced, and it is not a general filesystem-cleaning command.
Scheduling and operational policy
On a developer workstation, a monthly review of docker system df followed by targeted image or cache pruning is usually safer than an unconditional system-wide job. In CI, short-lived containers and builders can use age filters after artifacts and logs have been published. On production hosts, keep volume deletion out of unattended jobs, retain rollback images for a defined release window, and require an operator review before using -a or --volumes.
Track Docker Engine and API versions in the maintenance script. In particular, named-volume pruning with docker volume prune -a requires API 1.42 or later. If a command reports an unsupported option, stop and verify the client, daemon and API negotiation rather than substituting a broader command.
Choosing the least destructive command
Match the cleanup to the evidence from docker system df: use image prune for image buildup, container prune for exited jobs, network prune for abandoned custom networks, and builder or Buildx prune for cache. Use system prune only when several categories require attention and you have reviewed the combined scope. Keep volumes outside routine automation unless backups, labels and a documented retention policy make their deletion intentional.
Quick Recap
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.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errors




