Skip to content

Instantly share code, notes, and snippets.

@ivanrad
Created January 8, 2025 09:03
Show Gist options
  • Save ivanrad/7898a0ddd1442defe51c8aabbc6d7b5d to your computer and use it in GitHub Desktop.
Save ivanrad/7898a0ddd1442defe51c8aabbc6d7b5d to your computer and use it in GitHub Desktop.
docker_outdated.sh
#!/usr/bin/env bash
# Display which currently running docker images are outdated
set -eu -o pipefail
docker ps --format '{{ .Image }}' |
while read -r image; do
cur_digest=$(docker image inspect --format '{{ index .RepoDigests 0 }}' "$image" |
cut -d'@' -f2-)
latest_digest=$(regctl image digest "$image")
if [[ $cur_digest != $latest_digest ]]; then
printf '%s: current=%s; latest=%s\n' "$image" "$cur_digest" "$latest_digest"
else
printf '%s: ok\n' "$image"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment