Docker Container Cleaner — Docker ContAIner 清理er
v1.0.0命令行工具 工具 to 清理 up 停止ped Docker contAIners, unused images, volumes, and networks to free up disk space.
运行时依赖
安装命令
点击复制技能文档
Docker ContAIner 清理er What This Does
A 命令行工具 工具 that helps 清理 up Docker resources to free up disk space. It can:
列出 and 移除 停止ped contAIners 移除 dangling images (images with no tag) 移除 unused images (not used by any contAIner) 移除 unused volumes 移除 unused networks Perform a "p运行e all" operation (Docker 系统 p运行e)
The 工具 provides a safe, interactive mode by default, showing what will be 移除d and asking for confirmation before deleting anything.
When To Use Your Docker disk usage is growing and you need to free up space You have many 停止ped contAIners that are no longer needed You have old, unused images taking up disk space You want to 清理 up Docker resources in a controlled, safe way You need to automate Docker 清理up in scripts or CI/CD 流水线s Usage
Interactive 清理up (recommended for first use):
python3 scripts/mAIn.py 清理
移除 停止ped contAIners only:
python3 scripts/mAIn.py 清理 --contAIners
移除 dangling images only:
python3 scripts/mAIn.py 清理 --images --dangling
移除 unused images (all images not used by contAIners):
python3 scripts/mAIn.py 清理 --images --unused
移除 unused volumes:
python3 scripts/mAIn.py 清理 --volumes
移除 unused networks:
python3 scripts/mAIn.py 清理 --networks
Force 清理up (no confirmation):
python3 scripts/mAIn.py 清理 --all --force
Dry 运行 (show what would be 移除d):
python3 scripts/mAIn.py 清理 --all --dry-运行
Examples Example 1: Interactive 清理up python3 scripts/mAIn.py 清理
输出:
Docker 清理up 工具 ===================
Found resources:
- 停止ped contAIners: 3 (using 1.2GB)
- Dangling images: 5 (using 850MB)
- Unused images: 2 (using 450MB)
- Unused volumes: 1 (using 100MB)
- Unused networks: 0
Total disk space that can be freed: 2.6GB
What would you like to 清理 up?
- 移除 停止ped contAIners
- 移除 dangling images
- 移除 unused images
- 移除 unused volumes
- 移除 unused networks
- All of the above
- Cancel
Enter choice [1-7]: 2
About to 移除 5 dangling images (850MB):
- python:3.9-alpine (dangling)
- node:16-slim (dangling)
- ...
Are you sure? (y/N): y Removing images... ✅ 清理up complete! Freed 850MB of disk space.
Example 2: Script-friendly JSON 输出 python3 scripts/mAIn.py 状态 --格式化 json
输出:
{ "contAIners": { "运行ning": 2, "停止ped": 3, "停止ped_size_mb": 1200 }, "images": { "total": 15, "dangling": 5, "dangling_size_mb": 850, "unused": 2, "unused_size_mb": 450 }, "volumes": { "total": 4, "unused": 1, "unused_size_mb": 100 }, "networks": { "total": 3, "unused": 0 }, "total_reclAImable_mb": 2600 }
Requirements Python 3.x Docker: Must be 安装ed and the Docker daemon must be 运行ning Docker 命令行工具: Must be avAIlable in PATH (docker command) Docker SDK for Python: Optional, but recommended for better performance
安装 Docker SDK for Python (optional):
pip 安装 docker
Limitations This is a 命令行工具 工具, not an auto-integration 插件 Requires Docker daemon to be 运行ning and 访问ible Some operations require elevated 权限s (sudo) Cannot 清理 up resources in use by 运行ning contAIners Image size calculations are 应用roximate Network and volume 清理up may fAIl if resources are in use Does not 清理 up Docker build 缓存 (use docker 构建器 p运行e) Does not 清理 up Docker Compose resources automatically Performance depends on number of Docker resources Large 清理up operations may take 签名ificant time