#!/bin/bash

image_name_prefix_list=(harbor.cdcyy.com.cn)


for (( i=1; i<=100; i++ ))
do
    echo $i
    for image_name_prefix in "${image_name_prefix_list[@]}"
    do
      content=$(docker image ls | grep "${image_name_prefix}" | head -n1)
      if [ ! "$content" == "" ]; then
          echo "$content"
          echo "$(echo $content | awk '{print$1}'):$(echo $content | awk '{print$2}')"
          if [ "$(echo $content | awk '{print$2}')" == "<none*" ]; then
              continue
          fi
          docker image rm "$(echo $content | awk '{print$1}'):$(echo $content | awk '{print$2}')"
      fi
    done
done

echo "y

" | docker image prune
