Skip to content

Instantly share code, notes, and snippets.

@diversemix
Created June 13, 2016 15:22
Show Gist options
  • Save diversemix/aa58d5ff5cedacfbc501e92b899fa507 to your computer and use it in GitHub Desktop.
Save diversemix/aa58d5ff5cedacfbc501e92b899fa507 to your computer and use it in GitHub Desktop.
[docker] functions to access the registry api v2
#!/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