删除harbor项目下的所有镜像

user=
pswd=
url=
proid=

REPOS=$(curl -s -X GET --header 'Accept: application/json' "${url}/api/repositories?project_id=${proid}"|grep "name"|awk -F '"' '{print $4}')

for rp in ${REPOS}
do
  TAGS=$(curl -s -X GET --header 'Accept: application/json' "${url}/api/repositories/${rp}/tags"|grep \"name\"|awk -F '"' '{print $4}')
    for t in ${TAGS}
    do
        curl -u "${user}:${pswd}" -X DELETE -H "Content-Type: application/json" "${url}/api/repositories/${rp}/tags/${t}"
        echo ${URL}"/"${rp}":"${t} >> /app/container/docker.tag
    done
  echo "删除 ===> ${URL}\/${rp}\/${t}"
done
上一篇:this用法


下一篇:第三次作业-原型设计