一、定时清理无用 Docker images

1、 创建文件 /data/task/cleanimage.sh

  1. #! /bin/sh
  2. docker image prune -a -f --filter "until = 3h"
  3. docker rmi $(docker images | grep "none" | awk '{print $3}')

2、 设定定时清理时间

  1. crontab -e

设置早上上【6:30】执行一次清理命令

  1. 30 6 * * * /data/task/cleanimage.sh

查看 crontab 日志
/var/log/cron

参考:https://www.freesion.com/article/26681212757/