Azure / acr

Azure Container Registry samples, troubleshooting tips and references
https://aka.ms/acr
Other
163 stars 109 forks source link

az acr command to check the size of an image or list the size of all the images in repository #169

Open wamak9 opened 5 years ago

wamak9 commented 5 years ago

Is this a BUG REPORT or FEATURE REQUEST?:

FEATURE REQUEST

What happened?:

Seems like we are using more than allocated space for ACR in one of our subscriptions, since we dont have control over who pushes the images to ACR. We would like to know if there is a way on which image is taking up most of the space.

What did you expect to happen?:

I would like to add a feature request, so that we can have . az acr list image size --all -n <> --repository <>. something like that. which can help us determine who is taking up the space and see if that is really necessary.

Environment (if applicable to the issue):

peter-bannerflow commented 5 years ago

Would also be good to be able to see the total size on repository level if you list all repositories in a registry.

xorima commented 5 years ago

👍 Would be really good to see which images to target in a trimming down session

Spaceman1861 commented 5 years ago

It would be awesome if we could see this in the azure gui as well.

sajayantony commented 5 years ago

Would this help with the CLI

$ az acr repository show-manifests  --repository fatimage --detail --query '[].{Size: imageSize, Tags: tags}'
[
  {
    "Size": 4296278237,
    "Tags": [
      "4gb"
    ]
  }

For the portal we are working on this.

wamak9 commented 5 years ago

@sajayantony --It looks good, I can work with that. Let's hear from other people and see what they have to say and see if they have other suggestions.

So for the command above, I am guessing you guys have -n myregistry option right ? assuming people has multiple registries(we do).

az acr repository show-manifests -n bigfatregistry1 --repository fatimage --image bigimage --detail --query '[].{Size: imageSize, Tags: tags}'.

Thanks for working on this.

sajayantony commented 5 years ago

Yes it’s scoped to a registry and repository. https://docs.microsoft.com/en-us/cli/azure/acr/repository?view=azure-cli-latest#az-acr-repository-show-manifests

sajayantony commented 5 years ago

Closing since this is supported already. Portal work is being scheduled.

TiloGit commented 5 years ago

here quick hack to loop thru it:

arr_reglist=`az acr repository list -n yourRegName-o tsv`
 for myReg in ${arr_reglist[@]}
do
  az acr repository show-manifests -n yourRegName--repository $myReg --detail --query '[].{Size: imageSize, Tags: tags[0],Created: createdTime, Architecture: architecture, OS: os}' -o tsv | awk -v myReg="$myReg" '{ byte =$1 /1024/1024; print myReg ": " byte " MB", "Tag: "$2, $3, $4 ,$5 }'
 done
StingyJack commented 4 years ago

@sajayantony - can this get reopened? Any work for this on the portal hasn't happened in almost a year and typing in super long and specific console commands just to view image sizes is asking a bit much of users. Especially since the portal teases us with the total size of the repo.

sajayantony commented 2 years ago

As I understand this feature request is to see manifests in the portal. I'm adding @toddysm @SteveLasker and @mangalorereshmi since this needs to be prioritized. I would also track this as another issue since this one is about the CLI.

StingyJack commented 2 years ago

@sajayantony - I dont need to see manifests i want to see image sizes. If you want to track this in a separate issue thats up to you but users should be shown this info if their usage and billing is going to be affected by it.

vavsab commented 8 months ago

Developed a bit @TiloGit answer to get breakdown by each repo

registry=YOUR_REGISTRY_NAME

echo "Getting all repos..."
arr_reglist_str=`az acr repository list -n $registry -o tsv`

progress=0
total_items=$(echo "$arr_reglist_str" | wc -l)

while IFS= read -r repo; do
    ((progress++))
    printf "Calculating %d of %d: %s\n" "$progress" "$total_items" "$repo"
    az acr repository show-manifests -n $registry --only-show-errors --repository $repo --detail --query '[].{Size: imageSize}' -o tsv | awk -v repo="$repo" '{sum += $1} END {printf "%s %.2f GB\n", repo, sum /1024/1024/1024}'
done <<< "$arr_reglist_str"

Then you can clean not needed lines with regex bookmarking in Notepad++ and paste into Excel to get some chart/sorting to see who is eating the most of the space