hub-feedback
hub-feedback copied to clipboard
No API to delete tags
From https://github.com/docker/hub-feedback/issues/68#issuecomment-161839698 et seq.:
@posita wrote:
@nhsiehgit, is this UI only, or is there a corresponding API?
@nhsiehgit wrote:
@posita Just UI for now.
...
@posita wrote:
It's not a very intuitive interface. :disappointed: It's also two clicks per delete. With no batch option, and no API, if one has hundreds of tags to delete, it's going to take awhile. I guess it's better than nothing though. :persevere:
See also #250 and #368.
Thanks for filing this posita.
While the hub is currently built off API's, there's no current timeline to release officially supported api's.
Definitely a request we've heard and on our list of desired features
I'm creating new tags for new github branches - I'd also like to automatically delete tags when github branches get deleted - is there any other way to do it? or do I need to wait for this API to be released?
There is actually a fairly easy way to delete tags using the Docker Hub API at https://hub.docker.com/v2/ (instead of the Registry API at https://index.docker.io/v2/):
-
Request a JWT token It is required to send requests to the API:
curl -i -X POST \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{"username":"<HUB_USERNAME>","password":"<HUB_PASSWORD>"}' \ https://hub.docker.com/v2/users/login/HTTP/1.1 200 OK Content-Type: application/json Transfer-Encoding: chunked accept: application/json [...] {"token": "eyJ***************"} -
Delete the desired tag Pass the JWT token as a Authorization HTTP header:
curl -i -X DELETE \ -H "Accept: application/json" \ -H "Authorization: JWT eyJ***************" \ https://hub.docker.com/v2/repositories/<HUB_USERNAME>/<REPO>/tags/<TAG>/HTTP/1.1 204 NO CONTENT Content-Length: 0 [...] -
Logout (optional) Just in case you want to prevent the token from being reused.
curl -i -X POST \ -H "Accept: application/json" \ -H "Authorization: JWT eyJ***************" \ https://hub.docker.com/v2/logout/HTTP/1.1 200 OK Content-Type: application/json Transfer-Encoding: chunked [...] {"detail": "Logged out", "error": false}
Is there any particular reason the DELETE method isn't documented seven years later in the "latest" API docs at https://docs.docker.com/docker-hub/api/latest/#tag/repositories? Are there other undocumented parts of the API?
@dannysauer We now support the OCI endpoint for deletion. You can find the endpoint documented here: https://docs.docker.com/reference/api/registry/latest/
Awesome. Thanks for the follow-up, @sheltongraves