Docker-Tag-Exists.PS1
Created on Sun Jan 23 2022Last updated on Sun Jan 23 2022
# 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 $?
}
dockerTagExists.sh
Created on Sun Jan 23 2022Last updated on Sun Jan 23 2022
#!/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
}