Skip to content

Instantly share code, notes, and snippets.

@jwhonce
Created May 20, 2016 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwhonce/6a53366fb736714c43c91e8b7ca4067c to your computer and use it in GitHub Desktop.
Save jwhonce/6a53366fb736714c43c91e8b7ca4067c to your computer and use it in GitHub Desktop.
Example script for how to delete image from docker repositry 2.4
#!/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