Skip to content

delete manifests via registry api #1759

Closed

Description

@cblomart

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.

Activity

  1. manishtomar commented on Mar 6, 2019

    @manishtomar

    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.

  2. manishtomar commented on Mar 6, 2019

    @manishtomar

    Closing as non-issue.

  3. cblomart commented on Mar 7, 2019

    @cblomart
    Author

    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?

  4. manishtomar commented on Mar 7, 2019

    @manishtomar

    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.

  5. cblomart commented on Mar 8, 2019

    @cblomart
    Author

    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.

  6. cblomart commented on Mar 9, 2019

    @cblomart
    Author

    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}/

  7. ViBiOh commented on Jan 30, 2021

    @ViBiOh

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions