Docker定时清理

清理脚本

mkdir -p /data/script

sudo tee /data/script/docker_cleanup.sh <<-\'EOF\'
#!/bin/bash

# 执行Docker镜像和构建缓存清理
docker image prune -a -f
docker builder prune -a -f

echo "Docker cleanup executed at $(date)" >> /data/script/logs/docker_cleanup.log
EOF

chmod +x /data/script/docker_cleanup.sh

添加计划任务

crontab -e

0 1 * * * /data/script/docker_cleanup.sh

留下评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注