Skip to content

Instantly share code, notes, and snippets.

@valeriomazzeo
Created April 11, 2018 08:54
Show Gist options
  • Save valeriomazzeo/06b8e51e8b299654267d03991afd730d to your computer and use it in GitHub Desktop.
Save valeriomazzeo/06b8e51e8b299654267d03991afd730d to your computer and use it in GitHub Desktop.
List docker container tags from docker hub
REPO_NAME=myorg/myrepo
# get token from Docker Hub
DOCKER_HUB_TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${DOCKER_HUB_USERNAME}'", "password": "'${DOCKER_HUB_PASSWORD}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)
# get tags for repo
IMAGE_TAGS=$(curl -s -H "Authorization: JWT ${DOCKER_HUB_TOKEN}" https://hub.docker.com/v2/repositories/${REPO_NAME}/tags/?page_size=10000 | jq -r '.results|.[]|.name')
# generate a file containing each version on a new line excluding latest
printf '%s\n' ${IMAGE_TAGS#latest} > versions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment