Created
March 12, 2021 15:34
-
-
Save davidthewatson/d717af6d34f62d8d933635b5b6c23e2f to your computer and use it in GitHub Desktop.
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 | |
# get username and password | |
echo "Username?" | |
read UNAME | |
echo "Password?" | |
read UPASS | |
echo "This will delete ever repo in your dockerhub. Ctrl-C to end." | |
read | |
set -e | |
echo | |
# aquire token | |
TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${UNAME}'", "password": "'${UPASS}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token) | |
# get list of repositories for the user account | |
REPO_LIST=$(curl -s -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/${UNAME}/?page_size=100 | jq -r '.results|.[]|.name') | |
# delete every repo in list | |
for i in ${REPO_LIST} | |
do | |
curl -X DELETE -s -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/${UNAME}/${i}/ | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Every now and again I need to clear my dockerhub of cruft. That's everything.