Created
June 13, 2016 15:22
-
-
Save diversemix/aa58d5ff5cedacfbc501e92b899fa507 to your computer and use it in GitHub Desktop.
[docker] functions to access the registry api v2
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 | |
HOST=my_registry | |
getJsonVal () { | |
python -c "import json,sys;sys.stdout.write(json.dumps(json.load(sys.stdin)$1))"; | |
} | |
get_tags () { | |
i_name=$1 | |
curl -s ${HOST}:5000/v2/${i_name}/tags/list | getJsonVal "['tags']" | |
} | |
remove_image() { | |
i_name=$1 | |
i_ver=$2 | |
digest=$(curl -i -s -H "application/vnd.docker.distribution.manifest.v2+json" \ | |
-X GET http://${HOST}:5000/v2/${i_name}/manifests/${i_ver} \ | |
| grep Etag | cut -d '"' -f2) | |
echo Removing $digest | |
curl -v -X DELETE http://${HOST}:5000/v2/${i_name}/manifests/${digest} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment