#!/bin/bash
# Prerequisite
# 1) Install jq, azure-cli
# 2) Install docker and enable docker cli experiment feature
badimagefile="badimage_$(date +"%Y%m%dT%H%M").txt"
registry="myregistry"
subscription="mysubscription"
az login
az account set -s $subscription
az acr login -n $registry
echo "List all repositories in" $registry
az acr repository list -n $registry
az acr repository list -n $registry | jq -rc '.[]' | while IFS='' read repository;
do
echo "Start to list manifest from" $repository
az acr repository show-manifests -n $registry --repository $repository | jq -rc '.[].digest' | while IFS='' read manifest;
do
image=$registry.azurecr.io/$repository@$manifest
echo "Start to inspect manifest" $image
config=$(docker manifest inspect $image | jq -rc '.config //empty')
if [ ! -z $config ]; then
size=$(echo $config | jq -r '.size //empty')
if [ -z $size ]; then
echo $image "manifest contains config without size property"
echo $image >> $badimagefile
fi
fi
done
done
echo "=============================="
if [ -f "$badimagefile" ]; then
echo "BAD IMAGES FOUND"
cat $badimagefile
else
echo "NO BAD IMAGES FOUND"
fi
Last active
September 18, 2022 16:54
-
-
Save northtyphoon/c411bd78971ce7d0a2ab8c2bd23cea2c to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment