Skip to content

Instantly share code, notes, and snippets.

@40a
Forked from ryanmaclean/check_docker_tag.sh
Created June 27, 2017 14:07
Show Gist options
  • Save 40a/dc57dfca8a9aa75c70d3078b6f331730 to your computer and use it in GitHub Desktop.
Save 40a/dc57dfca8a9aa75c70d3078b6f331730 to your computer and use it in GitHub Desktop.
Check if Docker Image with Tag Exists
#!/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