-
-
Save itaysk/c023de03fe74dd3d5db336b7f9699b6b to your computer and use it in GitHub Desktop.
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 |
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 thishttps://hub.docker.com/_/nginx
, so we always get this_
. I can pull some information with this URLhttps://hub.docker.com/v2/repositories/nginx/
, but that's it.
maybe the command docker manifest inspect nginx:latest -v
is what you need
Thanks for this!
Thank you sir, I'm using it in my project and it works well (https://github.com/mmaous/sftp/blob/7c974165a25a34fd415d01637912e2b6b8b642bb/.github/workflows/docker-main.yml#L39)
Thank you for the code, I did some testing and improvements for my use case. Maybe these changes are helpful to anyone as well.
My strategy is to pull as little info (page_size=2) as possible in order to get to the result I am looking for:
curl -sL "https://hub.docker.com/v2/repositories/${DOCKERHUB_REPO}/${DOCKERHUB_IMAGE}/tags/?page_size=2" | \
jq '.results | .[] | .name' -r | \
sed '/latest/d' | \
head -n 1
@Reedef
For official docker images just use ${DOCKERHUB_REPO}=library
E.g.:
curl -sL "https://hub.docker.com/v2/repositories/library/alpine/tags/?page_size=2" | \
jq '.results | .[] | .name' -r | \
sed '/latest/d' | \
head -n 1
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 thishttps://hub.docker.com/_/nginx
, so we always get this_
. I can pull some information with this URLhttps://hub.docker.com/v2/repositories/nginx/
, but that's it.