Safely find and clean unused Docker resources
npm install dockleanSafely find and clean unused Docker resources from the command line.
- Node.js 18+
- Docker installed and the daemon running
Run directly with npx:
``bash`
npx docklean
Or install globally:
`bash`
npm install -g docklean
Scan only (no deletes):
`bash`
docklean
Interactive cleanup (prompts before delete):
`bash`
docklean --all
Selective cleanup:
`bash`
docklean --containers
Dry run (shows commands that would run):
`bash`
docklean --all --dry-run
Skip prompt:
`bash`
docklean --all --force
Filter by age:
`bash`
docklean --images --older-than 7d
- --containers Clean stopped/exited containers--images
- Clean unused/dangling images--volumes
- Clean unused volumes--networks
- Clean unused networks--cache
- Clean build cache--dangling
- Dangling images + stopped containers + unused volumes--all
- All unused resources--older-than
- Only clean items older than m/h/d/w--dry-run
- Print what would be removed--force
- Skip confirmation prompt--yes
- Alias for --force--json
- JSON output--quiet
- Minimal output--verbose
- More verbose output--no-color
- Disable colored output
- 0 Success1
- Docker CLI not found2
- Docker daemon not running3
- Nothing to clean or user declined4
- Partial failure5
- Invalid arguments
`bash``
npm install
npm run build
npm run dev -- --all --dry-run