Skip to content

Instantly share code, notes, and snippets.

@statianzo
Created September 15, 2014 20:43
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 statianzo/6e82d54cf05dfa8a45ad to your computer and use it in GitHub Desktop.
Save statianzo/6e82d54cf05dfa8a45ad to your computer and use it in GitHub Desktop.
Run command on docker image change
#!/bin/bash
set -eo pipefail
usage(){
echo "Usage: docker-check image [command]"
exit 1
}
version(){
docker history -q $1 | head -n 1
return 0
}
[ $# -eq 0 ] && usage
image=$1
shift 1
before=$(version $image)
docker pull $image 2>&1 > /dev/null
after=$(version $image)
if [ "$before" != "$after" ]; then
"$@"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment