Created
April 11, 2018 08:54
-
-
Save valeriomazzeo/06b8e51e8b299654267d03991afd730d to your computer and use it in GitHub Desktop.
List docker container tags from docker hub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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