Skip to content

Instantly share code, notes, and snippets.

@moisei
Created November 18, 2020 00:32
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save moisei/ef182a8c32b1bdd29139ad5c7f9ad2f0 to your computer and use it in GitHub Desktop.
Save moisei/ef182a8c32b1bdd29139ad5c7f9ad2f0 to your computer and use it in GitHub Desktop.
cleanup docker registry. delete all the tags from the list of the repositories
# inspired by the https://gist.github.com/jaytaylor/86d5efaddda926a25fa68c263830dac1
registry="http://${registry_user}:${registry_passwd}@${registry_url}/v2"
for repo in `cat repos-todel`; do
for tag in $(curl -sSL "${registry}/${repo}/tags/list" | jq -r '.tags[]?'); do
tagURL="${registry}/${repo}/manifests/${tag}"
sha256=$(curl -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -sSL -I ${tagURL} | awk '$1 == "Docker-Content-Digest:" { print $2 }' | tr -d $'\r')
deleteURL="${registry}/${repo}/manifests/${sha256}"
echo $deleteURL
# curl -v -sSL -X DELETE $deleteUR
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment