{"id":16777423,"url":"https://github.com/ryandaniels/docker-script-find-latest-image-tag","last_synced_at":"2025-09-08T09:41:37.025Z","repository":{"id":52581157,"uuid":"245028018","full_name":"ryandaniels/docker-script-find-latest-image-tag","owner":"ryandaniels","description":"Find Version Tag for Latest Docker Image","archived":false,"fork":false,"pushed_at":"2022-09-15T03:04:31.000Z","size":12,"stargazers_count":88,"open_issues_count":1,"forks_count":33,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-04T02:01:35.165Z","etag":null,"topics":["docker","docker-scripts"],"latest_commit_sha":null,"homepage":"https://ryandaniels.ca/blog/find-version-tag-latest-docker-image/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryandaniels.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-04T23:48:15.000Z","updated_at":"2025-03-16T11:13:09.000Z","dependencies_parsed_at":"2022-09-19T10:42:27.688Z","dependency_job_id":null,"html_url":"https://github.com/ryandaniels/docker-script-find-latest-image-tag","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/ryandaniels/docker-script-find-latest-image-tag","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryandaniels%2Fdocker-script-find-latest-image-tag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryandaniels%2Fdocker-script-find-latest-image-tag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryandaniels%2Fdocker-script-find-latest-image-tag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryandaniels%2Fdocker-script-find-latest-image-tag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryandaniels","download_url":"https://codeload.github.com/ryandaniels/docker-script-find-latest-image-tag/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryandaniels%2Fdocker-script-find-latest-image-tag/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274166615,"owners_count":25233958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-scripts"],"created_at":"2024-10-13T07:24:42.116Z","updated_at":"2025-09-08T09:41:36.757Z","avatar_url":"https://github.com/ryandaniels.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# docker-script-find-latest-image-tag\n\n(Over complicated) Bash script to find the version of a Docker image you are running when you took a shortcut and used \"latest\".  \nNow you don't know what image version was previously working, and a breaking change happened..\n\n`docker images` shows `image:\u003cnone\u003e` or `image:latest`. What image version am I using?  \n\nTag your images, and never use latest!\n\nThis script checks your local image's ID against every tag of an image in Docker Hub.  \n\nSome issues to note:  \nIssue #1: If the image no longer exists on the Docker Registry. You obviously won't find it.  \nIssue #2: The script doesn't work for Windows images. There are no manifests available for those.  \n\n## If you're lucky you can find the version tag\n\n### Trick #1\n\nIf you're lucky, the image's label will have the version. With a little `jq` magic you can get the good bits.\n\n```bash\n$ docker images\nREPOSITORY          TAG                 IMAGE ID            CREATED             SIZE\ntraefik             latest              96c63a7d3e50        2 months ago        85.7MB\n\n$ IMAGE_ID=96c63a7d3e50\n\n$ docker image inspect --format '{{json .}}' \"$IMAGE_ID\" | jq -r '. | {Id: .Id, Digest: .Digest, RepoDigests: .RepoDigests, Labels: .Config.Labels}'\n```\n\nOutput:\n\n```bash\n{\n  \"Id\": \"sha256:96c63a7d3e502fcbbd8937a2523368c22d0edd1788b8389af095f64038318834\",\n  \"Digest\": null,\n  \"RepoDigests\": [\n    \"traefik@sha256:5ec34caf19d114f8f0ed76f9bc3dad6ba8cf6d13a1575c4294b59b77709def39\"\n  ],\n  \"Labels\": {\n    \"org.opencontainers.image.description\": \"A modern reverse-proxy\",\n    \"org.opencontainers.image.documentation\": \"https://docs.traefik.io\",\n    \"org.opencontainers.image.title\": \"Traefik\",\n    \"org.opencontainers.image.url\": \"https://traefik.io\",\n    \"org.opencontainers.image.vendor\": \"Containous\",\n    \"org.opencontainers.image.version\": \"v1.7.20\"\n  }\n}\n```\n\n### Trick #2\n\nPull a bunch of images and hope the Image ID matches. Not much to this trick..\n\nIf you are unlucky, continue on..\n\n## Requirements\n\n- Docker or Podman\n- curl\n- jq\n- sed\n- tr\n- grep\n- sort\n- wc\n\n## Usage\n\nThe Docker image name (-n) must match the name (REPOSITORY) from \"docker images\". For example \"traefik\" (which is an \"Official\" image), or \"portainer/portainer\".  \n\n```bash\n./docker_image_find_tag.sh -h\nUsage:\n./docker_image_find_tag.sh [-n image name] [-i image-id]\nExample: ./docker_image_find_tag.sh -n traefik -i 96c63a7d3e50 -f 1.7\n  -n [text]: Image name (Required). '-n traefik' would reference the traefik image or '-n portainer/portainer' for portainer\n  -i [text]: Image ID. Required if Image ID (Long) (-L) is ommited.\n             Found in 'docker images'. Can also use -i image:tag\n  -L [text]: Image ID (Long). Required if Image ID (-i) is ommited\n      Example: -L sha256:96c63a7d3e502fcbbd8937a2523368c22d0edd1788b8389af095f64038318834\n      To find, it is Id from:\n      docker image inspect --format '{{json .}}' IMAGE_ID | jq -r '. | {Id: .Id, Digest: .Digest, RepoDigests: .RepoDigests, Labels: .Config.Labels}'\n  -D: Use Docker binary for Image ID check (Default) (Optional)\n  -P: Use Podman binary for Image ID check (Optional)\n  -r [text]: Registry URL to use. Example: -r https://index.docker.io/v2 (Default) (Optional)\n  -a [text]: Registry AUTH to use. Example: -a https://auth.docker.io (Default) (Optional)\n  -l [number]: Tag limit. Defaults to 100. (Optional)\n  -f [text]: Filter tag to contain this value (Optional)\n  -v: Verbose output (Optional)\n```\n\n## Usage Example\n\n```bash\n# ./docker_image_find_tag.sh -n traefik -i 96c63a7d3e50 -f 1.7. -l 10 -v\n\nUsing IMAGE_NAME: traefik\nUsing REGISTRY: https://index.docker.io/v2\nFound Image ID Source: sha256:96c63a7d3e502fcbbd8937a2523368c22d0edd1788b8389af095f64038318834\nFound Total Tags: 610\nFound Tags (after filtering): 178\nLimiting Tags to: 10\nLimit reached, consider increasing limit (-l [number]) or use more specific filter (-f [text])\n\nFound Tags:\nv1.7.21-alpine\nv1.7.21\nv1.7.20-alpine\nv1.7.20\nv1.7.19-alpine\nv1.7.19\nv1.7.18-alpine\nv1.7.18\nv1.7.17-alpine\nv1.7.17\n\nChecking for image match..\nFound match. tag: v1.7.20\nImage ID Target: sha256:96c63a7d3e502fcbbd8937a2523368c22d0edd1788b8389af095f64038318834\nImage ID Source: sha256:96c63a7d3e502fcbbd8937a2523368c22d0edd1788b8389af095f64038318834\n```\n\nThis example is searching for an image named traefik, with an image ID of `96c63a7d3e50` (which we got from running the command `docker images`.\n\nThe total number of tags for traefik images is 610! You could use this script to check every one, but that will take a minute or two. Instead, you can filter the results a bit. I *think* I’m running something in version 1.7.x. I’m also limiting the search to 10 tags in this example to keep the output small.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryandaniels%2Fdocker-script-find-latest-image-tag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryandaniels%2Fdocker-script-find-latest-image-tag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryandaniels%2Fdocker-script-find-latest-image-tag/lists"}