Last active
January 18, 2023 11:39
-
-
Save mag37/aa1133187be1076e58d2eed105543107 to your computer and use it in GitHub Desktop.
A function to use regctl to compare docker-container VS registry to check for available updates.
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
| ### Requires the regctl binary, either in PATH or as an alias | |
| ### Get it here: https://github.com/regclient/regclient/releases | |
| alias regctl="/path/to/regctl" | |
| regcheck () { | |
| if [[ -z "$1" ]]; then | |
| echo "No container name given, here's the list of currently running containers:" | |
| docker ps --format '{{.Names}}' | |
| else | |
| RepoUrl=$(docker inspect $1 --format='{{.Config.Image}}') | |
| LocalHash=$(docker image inspect $RepoUrl --format '{{.RepoDigests}}' | sed -e 's/.*sha256/sha256/' -e 's/\]$//') | |
| RegHash=$(regctl image digest --list $RepoUrl) | |
| if [[ "$LocalHash" != "$RegHash" ]] ; then printf "Updates available.\n" ; else printf "Already latest.\n" ; fi | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment