docker容器镜像检测清理脚本,采用docker容器ID方式清理
#!/bin/bash set -e cd /opt/soft docker images > docker-images.log cat docker-images.log |grep -v "test" |grep -v "hour" | grep -v "days ago" |awk -F ' ' '{print $3}' > docker-images1.log images=$(cat docker-images1.log ) for imageName in ${images[@]} ; do /bin/docker rmi $imageName echo "docker rmi $imageName" done
docker容器镜像检测清理脚本,采用docker容器镜像名方式清理
#!/bin/bash set -e cd /opt/soft /bin/docker images > docker-iamges.log cat docker-iamges.log |grep "GB" > docker-iamges1.log cat docker-iamges.log |grep "MB" >> docker-iamges1.log cat docker-iamges1.log |grep "hub.selinux.cn" |grep -v "none"|grep -v "test" |grep -v "hour" | grep -v "days ago" |awk -F ' ' '{print $1 ":" $2}' > docker-iamges2.log images=$(cat docker-iamges2.log ) for imageName in ${images[@]} ; do /bin/docker rmi $imageName echo "docker rmi $imageName" done