Inedo Community Forums Forums
    • Recent
    • Tags
    • Popular
    • Login

    Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

    If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

    deleting docker images via REST API

    Scheduled Pinned Locked Moved Support
    4 Posts 2 Posters 102 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J Offline
      James.McAllister_0459
      last edited by

      I am trying to use a PowerShell script to experiment with deleting docker images using the recently introduced REST API. When i issue the delete operation it returns a 401 error. I thus am assumed i needed to pass an API key. So i generated one with all permissions (overkill but it wasn't obvious which specific ones would apply). I passed that as a header and there was no change.

      The Uri value is the same one i used on a GET which returned the info on the image (config. digest, image layers etc)

      Invoke-RestMethod -Method DELETE -Uri https://MyServer/v2/Main/bhge/dcfr-microservices/manifests/280307 -ErrorVariable RestError -ErrorAction SilentlyContinue

      then went to

      Invoke-RestMethod -Method DELETE -Uri https://MyServer/v2/Main/bhge/dcfr-microservices/manifests/280307 -Headers @{"X-ApiKey" = "DdRBo6_mbzH80XEpXSfz" } -ErrorVariable RestError -ErrorAction SilentlyContinue

      i also tried a few other permutations but all end up with 401 errors.

      How should I really be doing this?

      1 Reply Last reply Reply Quote 0
      • benB Offline
        ben inedo-engineer
        last edited by

        Hello @James-McAllister_0459

        For the API key, use HTTP basic auth with api as the username and the API key as the password. You can also obtain a token via the Docker auth flow, but that's much more complicated.

        The manifest must be deleted by digest, not tag, so the URL should have /manifests/sha256: in it rather than just /manifests/ followed by a tag.

        1 Reply Last reply Reply Quote 0
        • J Offline
          James.McAllister_0459
          last edited by

          @James-McAllister_0459 said in deleting docker images via REST API:

          Invoke-RestMethod

          With that help i can now delete when i enter a digest. I had to switch to using Invoke-WebRequest rather than Invoke-RestMethod to get the response headers so i actually get the correct digest (read the docs again :-)

          Is there any way to get the published date or created date of the image from a REST api?

          I can see i could get it from the database and a join between the DockerImages and DockerImageTags tables.

          benB 1 Reply Last reply Reply Quote 0
          • benB Offline
            ben inedo-engineer @James.McAllister_0459
            last edited by

            @James-McAllister_0459 said in deleting docker images via REST API:

            Is there any way to get the published date or created date of the image from a REST api?

            The Docker API in ProGet doesn't (currently) return a Last-Modified header, but depending on which date you want, it can still be accessed:

            Published date can be accessed via the native API using the tables you identified. However, this API is generated directly from internal ProGet database procedures, so this may break in the (unlikely) event that ProGet's Docker database structure changes.

            Created date is a property of the image, which is embedded in the manifest's config field. Inside the JSON blob referenced by the manifest, the creation date of the image is in a field named created. This is optional in the Docker specification, but if you're building your own images, it should always be present.

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • 1 / 1
            • First post
              Last post
            Inedo Website Home • Support Home • Code of Conduct • Forums Guide • Documentation