{"id":11088,"date":"2024-08-01T20:43:00","date_gmt":"2024-08-02T01:43:00","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=11088"},"modified":"2024-08-04T13:50:21","modified_gmt":"2024-08-04T18:50:21","slug":"docker-registry-listing-images-and-timestamps","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=11088","title":{"rendered":"Docker Registry: Listing Images and Timestamps"},"content":{"rendered":"\n<p>I wanted a quick way to verify that Docker images have actually been pushed to the registry &#8230; I&#8217;m using <a href=\"https:\/\/github.com\/distribution\/distribution\" data-type=\"link\" data-id=\"https:\/\/github.com\/distribution\/distribution\" target=\"_blank\" rel=\"noreferrer noopener\">Distribution<\/a>, and only wanted to report on images that start with sample (because the repository is shared &amp; I don&#8217;t want to read through the very long list of other people&#8217;s images)<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n#!\/bin\/bash\n\nregistry=&quot;registryhost.example.net:5443&quot;\nauthHeader=&quot;Authorization: Basic AUTHSTRINGHERE&quot;\n\n# List all repositories\nrepositories=$(curl -s -H &quot;$authHeader&quot; https:\/\/$registry\/v2\/_catalog | jq -r &#039;.repositories&#x5B;]&#039;)\n\nfor repo in $repositories; do\n  # Check if the repository name starts with &quot;npm&quot;\n  if &#x5B;&#x5B; $repo == sample* ]]; then\n\n    # List all tags for the repository\n    tags=$(curl -s -H &quot;$authHeader&quot; https:\/\/$registry\/v2\/$repo\/tags\/list | jq -r &#039;.tags&#x5B;]&#039;)\n\n    for tag in $tags; do\n\n      # Get the manifest for the tag\n      manifest=$(curl -s -H &quot;$authHeader&quot; -H &quot;Accept: application\/vnd.docker.distribution.manifest.v2+json&quot; https:\/\/$registry\/v2\/$repo\/manifests\/$tag)\n\n      # Extract the digest for the config\n      configDigest=$(echo $manifest | jq -r &#039;.config.digest&#039;)\n\n      # Get the config blob\n      configBlob=$(curl -s -H &quot;$authHeader&quot; https:\/\/$registry\/v2\/$repo\/blobs\/$configDigest)\n\n      # Extract the last modified date from the config history\n      lastModifiedDate=$(echo $configBlob | jq -r &#039;&#x5B;.history&#x5B;].created] | max&#039;)\n\n      echo -e &quot;$repo\\t$tag\\t$lastModifiedDate&quot;\n    done\n  fi\ndone\n\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>I wanted a quick way to verify that Docker images have actually been pushed to the registry &#8230; I&#8217;m using Distribution, and only wanted to report on images that start with sample (because the repository is shared &amp; I don&#8217;t want to read through the very long list of other people&#8217;s images)<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[623],"tags":[632,671,2034,231,2035],"class_list":["post-11088","post","type-post","status-publish","format-standard","hentry","category-containerized-development-and-deployment","tag-bash","tag-bash-script","tag-distribution","tag-docker","tag-registry"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/11088","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11088"}],"version-history":[{"count":1,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/11088\/revisions"}],"predecessor-version":[{"id":11089,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/11088\/revisions\/11089"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11088"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11088"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11088"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}