Skip to content

Instantly share code, notes, and snippets.

@B-Stefan
Created January 3, 2018 12:56
Show Gist options
  • Save B-Stefan/b586f134ccc14bd8f983b2403423a99a to your computer and use it in GitHub Desktop.
Save B-Stefan/b586f134ccc14bd8f983b2403423a99a to your computer and use it in GitHub Desktop.
Docker check if tag exists
export DOCKER_TAG=test
if [[ $( docker pull hello-world:$DOCKER_TAG 2>&1 | head -1 ) == *"not found"* ]] ;
then
echo "Create image for hello world repro"
docker pull hello-world:develop
docker tag hello-world:develop hello-world:$DOCKER_TAG
docker push hello-world:$DOCKER_TAG
else
echo "Image already exists"
fi
@B-Stefan
Copy link
Author

B-Stefan commented Jan 3, 2018

This script checks if a specific tag exists.
If the tag was found the pull will be canceled and not downloaded!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment