shell - 清理docker标准输出与无用镜像
2022-10-26
清理docker标准输出与无用镜像
#!/bin/bash
logs=$(find /var/lib/docker/containers -name *-json.log)
for log in ${logs}
do
cat /dev/null > ${log}
done
images=$(docker images | grep -v yqn-library | awk '{print $3}' | grep -v "IMAGE")
for image in ${images}
do
docker rmi ${image}
done
docker system prune -f
查找docker中临时存储占比top10的容器
#!/bin/bash
cd /var/lib/docker/overlay2/
paths=$(du -shm * | sort -rnk1 | awk '{print $NF}' |head)
docker_containers=$(docker ps -qa)
for path in ${paths}
do
for docker_container in ${docker_containers}
do
docker inspect ${docker_container} | grep ${path} > /dev/null
if [[ $? -eq 0 ]];then
echo ${docker_container} ${path}
fi
done
done
标题:shell - 清理docker标准输出与无用镜像
地址:https://blog.njqhome.com:8443/articles/2022/03/09/1646810371856.html