Last active
January 23, 2022 16:35
-
-
Save webbertakken/1789a4683a99e2a62b975ff436a85382 to your computer and use it in GitHub Desktop.
Check whether an image exists Dockerhub.
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
# 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 $? | |
} | |
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/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