furniture-3d-system-Wu/scripts/docker-cleanup.ps1
WuYongJie 5821d73291 初始提交:3D家具安装展示系统
包含:
- furniture-3d-system:Next.js 16 全栈应用(资产中心、产品管理、3D装配动画)
- autocad-plugin:AutoCAD 家具导出插件源码
- 资产中心改造:编辑弹窗化、删除功能、Toast反馈、自定义Select组件

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-02 14:00:19 +08:00

58 lines
2.1 KiB
PowerShell

# Docker 自动清理脚本
# 用途:定期清理 Docker 数据,防止 VHDX 文件过大
# 使用:手动运行或设置为计划任务
Write-Host "=== Docker 清理开始 ===" -ForegroundColor Cyan
Write-Host "时间: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')`n" -ForegroundColor Yellow
# 1. 显示清理前的空间使用
Write-Host "清理前的空间使用:" -ForegroundColor Yellow
docker system df
Write-Host ""
# 2. 清理停止的容器
Write-Host "清理停止的容器..." -ForegroundColor Yellow
$containers = docker container prune -f
Write-Host $containers -ForegroundColor Gray
# 3. 清理未使用的镜像
Write-Host "`n清理未使用的镜像..." -ForegroundColor Yellow
$images = docker image prune -a -f
Write-Host $images -ForegroundColor Gray
# 4. 清理未使用的卷
Write-Host "`n清理未使用的卷..." -ForegroundColor Yellow
$volumes = docker volume prune -f
Write-Host $volumes -ForegroundColor Gray
# 5. 清理构建缓存
Write-Host "`n清理构建缓存..." -ForegroundColor Yellow
$cache = docker builder prune -a -f
Write-Host $cache -ForegroundColor Gray
# 6. 显示清理后的空间使用
Write-Host "`n清理后的空间使用:" -ForegroundColor Green
docker system df
# 7. 检查 VHDX 文件大小
Write-Host "`n检查 VHDX 文件大小..." -ForegroundColor Yellow
$vhdxPath = "D:\Users\Mr_Wu01\Documents\DockerDesktopWSL\disk\docker_data.vhdx"
if (Test-Path $vhdxPath) {
$vhdxSize = [math]::Round((Get-Item $vhdxPath).Length/1GB, 2)
if ($vhdxSize -gt 50) {
Write-Host "⚠️ VHDX 文件较大: $vhdxSize GB" -ForegroundColor Red
Write-Host "建议运行压缩脚本: .\scripts\docker-compress-vhdx.ps1" -ForegroundColor Yellow
} elseif ($vhdxSize -gt 20) {
Write-Host "⚠️ VHDX 文件: $vhdxSize GB (建议关注)" -ForegroundColor Yellow
} else {
Write-Host "✅ VHDX 文件: $vhdxSize GB (正常)" -ForegroundColor Green
}
} else {
Write-Host "❌ 未找到 VHDX 文件" -ForegroundColor Red
}
Write-Host "`n=== 清理完成 ===" -ForegroundColor Green
Write-Host "节省的空间请查看上方统计信息" -ForegroundColor Cyan