Skip to content

Instantly share code, notes, and snippets.

@iksnae
Forked from byrnedo/check_docker_newer_tag.sh
Created July 26, 2018 04:21
Show Gist options
  • Select an option

  • Save iksnae/f4b371a88850f76d9b85fad651fdd60b to your computer and use it in GitHub Desktop.

Select an option

Save iksnae/f4b371a88850f76d9b85fad651fdd60b to your computer and use it in GitHub Desktop.
Check if newer docker image available.
#!/bin/bash
# ensure running bash
if ! [ -n "$BASH_VERSION" ];then
echo "this is not bash, calling self with bash....";
SCRIPT=$(readlink -f "$0")
/bin/bash $SCRIPT
exit;
fi
REGISTRY="my.registry.com:5000"
REPOSITORY="awesome-project-of-awesomeness"
LATEST="`wget -qO- http://$REGISTRY/v1/repositories/$REPOSITORY/tags`"
LATEST=`echo $LATEST | sed "s/{//g" | sed "s/}//g" | sed "s/\"//g" | cut -d ' ' -f2`
RUNNING=`docker inspect "$REGISTRY/$REPOSITORY" | grep Id | sed "s/\"//g" | sed "s/,//g" | tr -s ' ' | cut -d ' ' -f3`
if [ "$RUNNING" == "$LATEST" ];then
echo "same, do nothing"
else
echo "update!"
echo "$RUNNING != $LATEST"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment