Skip to content

Instantly share code, notes, and snippets.

@webbertakken
Last active January 23, 2022 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webbertakken/1789a4683a99e2a62b975ff436a85382 to your computer and use it in GitHub Desktop.
Save webbertakken/1789a4683a99e2a62b975ff436a85382 to your computer and use it in GitHub Desktop.
Check whether an image exists Dockerhub.
# Check whether a docker image exists on Dockerhub.
#
# Usage:
# if (Docker-Tag-Exists -Repository "unityci/base" -Tag "windows-0.17.0") {
# echo "Image exists."
# } else {
# echo "Image does not exist."
# }
function Docker-Tag-Exists {
[CmdletBinding()]
param([string] $Repository, [string] $Tag)
Try {
Invoke-RestMethod "https://index.docker.io/v1/repositories/$Repository/tags/$Tag"
} Catch {} # Assume image does not exist on erroneous response
return $?
}
#!/bin/sh
# Check whether a docker image exists on Dockerhub.
#
# Source: https://stackoverflow.com/a/39731444/3593896
#
# Usage:
# if docker_tag_exists "unityci/base" "ubuntu-0.17.0" ; then
# echo "Image exists."
# else
# echo "Image does not exists."
# fi
function docker_tag_exists() {
curl --silent -f -lSL https://index.docker.io/v1/repositories/$1/tags/$2 > /dev/null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment