Created
May 15, 2016 08:16
-
-
Save vchrisb/bd2497b8ff38c10473357e02c6fdb9e9 to your computer and use it in GitHub Desktop.
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 | |
| echo "Updating images:" | |
| docker images | grep -v '^<none>' | grep -v '^REPOSITORY' | awk '{print $1}' | xargs -L1 docker pull | grep 'Status' | |
| echo -e "\nChecking if a container is not running the latest image:" | |
| CIDS=$(docker ps | grep -v '^CONTAINER ID' | awk '{print $1}') | |
| for CID in $CIDS | |
| do | |
| RUNNING=`docker inspect --type=container --format "{{.Image}}" $CID` | |
| IMAGE=`docker inspect --type=container --format "{{.Config.Image}}" $CID` | |
| LATEST=`docker inspect --type=image --format "{{.Id}}" $IMAGE` | |
| NAME=`docker inspect --format '{{.Name}}' $CID | sed "s/\///g"` | |
| # echo "Latest:" $LATEST | |
| # echo "Running:" $RUNNING | |
| if [ "$RUNNING" != "$LATEST" ];then | |
| echo "$NAME is outdated" | |
| else | |
| echo "$NAME up to date" | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment