#!/bin/bash VERBOSE=false ec() { if $VERBOSE; then echo -en $1; fi } for IMAGE in $(docker images | grep -v '^REPOSITORY' | cut -f1 -d' ') do ec "Fetching Docker Hub token...\n" token=$(curl --silent "https://auth.docker.io/token?scope=repository:$IMAGE:pull&service=registry.docker.io" | jq -r '.token') ec "Fetching remote digest... " digest=$(curl --silent -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \ -H "Authorization: Bearer $token" \ "https://registry.hub.docker.com/v2/$IMAGE/manifests/latest" | jq -r '.config.digest') ec "$digest\n" ec "Fetching local digest... " local_digest=$(docker images -q --no-trunc $IMAGE:latest) ec "$local_digest\n" if [ "$digest" != "$local_digest" ] ; then echo "Update available for: $IMAGE" else echo "Already up to date. Nothing to do for: $IMAGE" fi done