Skip to content

Instantly share code, notes, and snippets.

@itaysk
Last active June 17, 2024 02:43
Show Gist options
  • Save itaysk/c023de03fe74dd3d5db336b7f9699b6b to your computer and use it in GitHub Desktop.
Save itaysk/c023de03fe74dd3d5db336b7f9699b6b to your computer and use it in GitHub Desktop.
Get latest (highest) version of a Docker Hub image
curl -L --fail "https://hub.docker.com/v2/repositories/${DOCKERHUB_REPO}/${DOCKERHUB_IMAGE}/tags/?page_size=1000" | \
jq '.results | .[] | .name' -r | \
sed 's/latest//' | \
sort --version-sort | \
tail -n 1
@Staubgeborener
Copy link

Interesting workaround, but could you provide a working example with "official" images (like alpine, Nextcloud, nginx)? A lot of repository looks like this: https://hub.docker.com/r/nodered/node-red/ which works with your code, but official images looks more like this https://hub.docker.com/_/nginx, so we always get this _. I can pull some information with this URL https://hub.docker.com/v2/repositories/nginx/, but that's it.

@Reedef
Copy link

Reedef commented Jan 21, 2024

Interesting workaround, but could you provide a working example with "official" images (like alpine, Nextcloud, nginx)? A lot of repository looks like this: https://hub.docker.com/r/nodered/node-red/ which works with your code, but official images looks more like this https://hub.docker.com/_/nginx, so we always get this _. I can pull some information with this URL https://hub.docker.com/v2/repositories/nginx/, but that's it.

maybe the command docker manifest inspect nginx:latest -v is what you need

@amerkurev
Copy link

Thanks for this!

@mmaous
Copy link

mmaous commented May 23, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment