Overview
Remove unused Docker images from an environment to reclaim disk space. Supports pruning dangling images (untagged) or all unused images (including tagged images not used by any container).Endpoint
Query Parameters
Environment ID to prune images from. Optional for local environments.
Prune mode:
trueor omitted: Remove only dangling images (untagged)false: Remove all unused images including tagged ones
Authentication
Requiresimages:remove permission for the specified environment.
Response Format
Returns job ID for progress tracking:Result Format
The final result contains deleted images and space reclaimed:Response Fields
Array of deleted/untagged image objects:
Deleted: Image SHA256 that was removedUntagged: Image tag that was removed
Total disk space reclaimed in bytes
Prune Modes
Dangling Only (default)
Removes only untagged images (labeled<none>:<none>):
All Unused Images
Removes all images not currently used by any container:Implementation
Docker API Integration
The prune operation uses Docker’s native prune API:Docker API uses
dangling=false to prune all unused images, which is counterintuitive. The filter specifies what to keep, not what to remove.Usage Examples
Prune Dangling Images
Prune All Unused Images
Track Prune Progress
Automated Cleanup Script
Error Responses
Permission denied - user lacks
images:remove permissionPrune operation failed
Scheduled Pruning
Dockhand supports automatic image pruning via the scheduler:Audit Logging
Prune operations are logged with full details:- Number of images removed
- Space reclaimed
- Prune mode (dangling vs all unused)
- User who initiated the operation
Related Operations
- List Images - View available images
- Delete Image - Remove specific images
- System Prune - Prune all unused resources
- Storage Management - Monitor disk usage
Best Practices
- Regular Dangling Prune: Run dangling-only prune regularly (daily/weekly) to remove build artifacts
-
Conservative All-Unused Prune: Only use
dangling=falsewhen disk space is critically low -
Monitor Impact: Check
SpaceReclaimedto track cleanup effectiveness - Automated Cleanup: Configure scheduled pruning in environment settings
- Pre-deployment Prune: Prune before deploying new images to ensure available space
- Combine with System Prune: For maximum space recovery, use system-wide prune operations
Notes
- Prune operations only affect unused images
- Images referenced by containers (running or stopped) are never pruned
- Dangling images are typically intermediate build layers
- Tagged images are only removed with
dangling=false - Operations are atomic - either all images are pruned or none
- Space reclaimed includes all image layers no longer referenced
- Audit logs track all prune operations for compliance
