Created
May 20, 2016 17:05
-
-
Save jwhonce/6a53366fb736714c43c91e8b7ca4067c to your computer and use it in GitHub Desktop.
Example script for how to delete image from docker repositry 2.4
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 -ex | |
name='kubernetes/pause' | |
docker stop registry && docker rm -v registry ||: | |
rm -rf /var/registry/* ||: | |
ENV='-e REGISTRY_STORAGE_DELETE_ENABLED=true -e REGISTRY_LOG_LEVEL=debug' | |
docker run -d -p 5000:5000 --restart=always $ENV --volume /var/registry:/var/lib/registry --name registry registry:2.4 | |
docker pull $name | |
docker tag $name localhost:5000/$name | |
docker push $_ | |
curl -siL -X GET -w '\nresponse: %{http_code}\n' http://localhost:5000/v2/ | |
header='Accept:application/vnd.docker.distribution.manifest.v2+json' | |
curl -siL -X GET -H $header http://localhost:5000/v2/_catalog | |
curl -siL -X GET -H $header http://localhost:5000/v2/$name/tags/list | |
blob=$(curl -sL -X GET -H $header http://localhost:5000/v2/$name/manifests/latest) | |
jq '.' <<<$blob | |
digest=$(jq -r '(.config.digest)' <<<$blob) | |
du -sh /var/registry | |
curl -siL -X DELETE http://localhost:5000/v2/$name/manifests/$digest | |
du -sh /var/registry |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment