hub-feedback icon indicating copy to clipboard operation
hub-feedback copied to clipboard

No API to delete tags

Open posita opened this issue 9 years ago • 5 comments

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:

posita avatar Dec 04 '15 16:12 posita

See also #250 and #368.

posita avatar Dec 04 '15 16:12 posita

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

nhsiehgit avatar Dec 04 '15 18:12 nhsiehgit

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?

pgrm avatar Jul 08 '16 16:07 pgrm

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/):

  1. 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***************"}
    
  2. 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
    [...]
    
    
  3. 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}
    

antoineco avatar Feb 06 '17 00:02 antoineco

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 avatar May 24 '24 17:05 dannysauer

@dannysauer We now support the OCI endpoint for deletion. You can find the endpoint documented here: https://docs.docker.com/reference/api/registry/latest/

sheltongraves avatar May 28 '25 18:05 sheltongraves

Awesome. Thanks for the follow-up, @sheltongraves

dannysauer avatar May 28 '25 18:05 dannysauer