Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete manifests via registry api #1759

Closed
cblomart opened this issue Mar 2, 2019 · 7 comments
Closed

delete manifests via registry api #1759

cblomart opened this issue Mar 2, 2019 · 7 comments

Comments

@cblomart
Copy link

cblomart commented Mar 2, 2019

Problem description

I am building a opensource project with CI/CD.
Every commit is builded and pushed to docker hub with the short commit number as their tag.

I wanted to find a way to cleanup old commit builds but keep a few (i.e. last 15 days and at least 3).

i.e.
a little tool that would take a few argument:

  • repository to run against
  • regex match for tags
  • days to keep
  • minimum number of tags to keep

I looked at registry api against registry-1.docker.io. And i am able to list tags with details without any issues.
Delete manifests is apparently supported there.
doing a delete on https://registry-1.docker.io/v2/{repo}/maniftests/{digest} responds with:

{"errors":[{"code":"UNSUPPORTED","message":"The operation is unsupported."}]}

From my reading of it, it seems that delete has not been disabled on the backend registry.

@manishtomar
Copy link
Contributor

Delete has been disabled in hub registry. If needed please delete tag from Hub API DELETE hub.docker.com/v2/repositories/{repo}/tags/{tag}. You will authenticate though.

@manishtomar
Copy link
Contributor

Closing as non-issue.

@cblomart
Copy link
Author

cblomart commented Mar 7, 2019

Both api's apparently are protected by the same authenication/authorization mechanism but a specific api is needed for docker hub?
For people making use of registries it sounds to me that generic tools and api looks better.

Could you elaborate on the reason not to trust delete at the registry api level?

@manishtomar
Copy link
Contributor

manishtomar commented Mar 7, 2019

Disabling delete was probably done before me but I am guessing it is because that API was getting implemented at that time. Blocking deletes is also safer as user have called it by mistake. Deleting from Hub allows us to fine tune the delete.

Note that although you are free to call registry APIs directly we do not guarantee that every registry API will be implemented. Our primary focus is to ensure it works seamlessly with Docker CLI.

@cblomart
Copy link
Author

cblomart commented Mar 8, 2019

If operations needs to go trough:
hub.docker.com/v2/repositories/{repo}/tags/{tag}

A documentations of the API would be realy nice!
I am currently trying to get all tags via this api and the pagination does give me a headache.

@cblomart
Copy link
Author

cblomart commented Mar 9, 2019

Btw the url that seem to work is not hub.docker.com/v2/repositories/{repo}/tags/{tag} but cloud.docker.com/v2/repositories/{repo}/tags/{tag}/

@ViBiOh
Copy link

ViBiOh commented Jan 30, 2021

I found this issue when trying to delete tags from the Docker registry instead of DockerHub.

If I curl the DockerHub API, I only have latest tag

$ curl "https://hub.docker.com/v2/repositories/vibioh/goweb/tags/?page_size=100"
{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "images": [...],
      "name": "latest",
      "v2": true,
      "tag_status": "active"
    }
  ]
}

But if I do the same on the registry directly, I got much more answer

$ curl https://registry.docker.io/v2/vibioh/goweb/tags/list
{"name":"vibioh/goweb","tags":["02c7d13","037c0bf",[ 200 items ],"ff8a030","latest"]}

I was used to clean my repositories by using that query.

curl --request DELETE "https://hub.docker.com/v2/repositories/vibioh/goweb/tags/${tag}/"

When I saw that registry still contains the old tags, I tried to delete them with the manifest references but encountered the same issue than @cblomart .

Is this something expected?

My main point is that when using flux with image update automation, it founds tags that are still listed by the Docker Registry but not available from the DockerHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants