27 lines
958 B
Bash
27 lines
958 B
Bash
#!/bin/bash
|
|
|
|
# 이미지 소스 리스트
|
|
registries=("none" "docker.io" "registry.k8s.io" "quay.io" "ghcr.io" "$(ip a show ens192 |grep inet |awk '{print $2}'| cut -d/ -f1)")
|
|
|
|
echo -e ""
|
|
|
|
for registry in "${registries[@]}"; do
|
|
count=$(podman images | grep "$registry" | wc -l)
|
|
|
|
if [ "$count" -eq 0 ]; then
|
|
echo -e "\033[33mNo search ${registry} container image\033[0m"
|
|
else
|
|
echo -e "\033[32mDelete ${registry} container images: \033[31m$count \033[0m"
|
|
|
|
# none은 이름 대신 ID로 삭제, 그 외에는 태그로 삭제
|
|
if [ "$registry" == "none" ]; then
|
|
podman images | grep "$registry" | awk '{print $3}' | xargs -r -I {} podman rmi {} > /dev/null 2>&1
|
|
else
|
|
podman images | grep "$registry" | awk '{print $1":"$2}' | xargs -r -I {} podman rmi {} > /dev/null 2>&1
|
|
fi
|
|
fi
|
|
done
|
|
|
|
echo -e "\n결과 출력\n"
|
|
podman images
|
|
echo -e "\n\033[31m일부 이미지는 사용중으로 삭제 되지 않습니다!\033[0m\n" |