Created
September 29, 2016 18:05
-
-
Save ryanmaclean/36ac895bac381747a082955601237770 to your computer and use it in GitHub Desktop.
Check if Docker Image with Tag Exists
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
#!/bin/bash | |
# This script will check to see if a Docker image exists for a specific tag. | |
# Taken from here, with love: https://www.reddit.com/r/docker/comments/4hwdma/check_if_an_image_tag_for_a_private_repo_exists/ | |
TOKEN=$( curl -sSLd "username=${DOCKER_HUB_USERNAME}&password=${DOCKER_HUB_PASSWORD}" https://hub.docker.com/v2/users/login | jq -r ".token" ) | |
curl -sH "Authorization: JWT $TOKEN" "https://hub.docker.com/v2/repositories/${DOCKER_REPO}/tags/${DOCKER_TAG}/" | jq . | |
#{ | |
# "name": "latest", | |
# "id": 780668, | |
# "repository": 295322, | |
# "creator": 2215, | |
# "last_updater": 2215, | |
# "last_updated": "2016-04-28T03:45:35.148832Z", | |
# "image_id": null, | |
# "v2": true, | |
# "platforms": [] | |
#} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment