Last active
March 18, 2022 13:23
-
-
Save anderson-pids/ee2b641883102386e7898e3c7a3d6c8d to your computer and use it in GitHub Desktop.
Getting size of all repos and tags into dockerhub organization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#set you organization | |
ORG=ORGANIZATION | |
# using tool of dockerhub to list repos and get tags: https://github.com/docker/hub-tool#readme | |
PATH_HUBTOOL=./hub-tool | |
REPO_DATA_PATH=dockerhub-raw-repos.data | |
REPO_DATA_LIST=repos.data | |
echo "Getting dockerhub repositories.." | |
echo "Created: $REPO_DATA_PATH" | |
${PATH_HUBTOOL} repo ls --all --format json meliuz --all > ${REPO_DATA_PATH} | |
echo "Created: $REPO_DATA_LIST" | |
cat ${REPO_DATA_PATH} | jq ".[].Name" | tr -d '",' > ${REPO_DATA_LIST} | |
# Loop over repos | |
(( total = 0 )) | |
while read repo; do | |
echo "Acessing $repo.." | |
total_repo=$(${PATH_HUBTOOL} tag ls --all --format json $repo | jq '.[].FullSize' | awk '{s+=$1} END {printf "%.2f",s/1000000000 }' | tr , .) | |
total=$(echo "scale=2;$total+$total_repo" | bc -l) | |
echo "repo: $total_repo GB" | |
echo "total: $total GB" | |
printf "\n\n" | |
done <${REPO_DATA_LIST} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment