Created
September 15, 2014 20:43
-
-
Save statianzo/6e82d54cf05dfa8a45ad to your computer and use it in GitHub Desktop.
Run command on docker image change
This file contains hidden or 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/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