Skip to content

Instantly share code, notes, and snippets.

@anderson-pids
Created March 18, 2022 13:22
Get size of storage for dockerhub organization - Top 10 most updated tags
#!/bin/bash
#set your Organization and change top number if you want
ORG=ORGANIZATION
TOP=10
# 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 --sort updated --format json $repo | jq '.[].FullSize' | head -n $TOP | 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