Update from Sync Service

This commit is contained in:
FNS Service
2026-04-21 20:10:48 +08:00
parent ce5e80bda6
commit 439753fb97
4 changed files with 209 additions and 3 deletions

62
Docker/Docker镜像清理.md Executable file
View File

@@ -0,0 +1,62 @@
# Docker 镜像清理
## 清理无用镜像
### 方法一prune 命令(推荐)
```bash
# 清理悬空镜像(无 tag 的镜像)
docker image prune -f
# 清理所有未使用镜像
docker image prune -a -f
```
### 方法二:批量清理
```bash
# 批量删除所有无用镜像,不会影响正在使用的镜像
docker images | awk 'NR!=1{print $1":"$2}' | xargs docker rmi
```
### 方法三system prune全面清理
```bash
# 清理所有未使用的容器、网络、镜像
docker system prune -f
# 清理所有未使用的镜像,不仅仅是悬空镜像
docker system prune -a -f
# 清理卷(注意:会删除数据)
docker system prune --volumes -f
```
## 清理前后对比
```bash
# 查看清理前
docker images -a
# 清理
docker system prune -f
# 查看清理后
docker images -a
```
## 定时清理(可选)
创建 cron 任务定期清理:
```bash
# 编辑 crontab
crontab -e
# 每周日凌晨 3 点清理
0 3 * * 0 /usr/bin/docker system prune -f
```
---
> 参考:[Docker 官方文档](https://docs.docker.com/config/pruning/)