2023-01-18 10:54:03 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-01-18 10:53:28 +00:00
|
|
|
### Requires the regctl binary, either in PATH or as an alias
|
|
|
|
### Get it here: https://github.com/regclient/regclient/releases
|
|
|
|
|
2023-01-18 19:55:51 +00:00
|
|
|
### Preferably placed in .bashrc or similar
|
|
|
|
|
|
|
|
### if regctl is not in PATH, set the alias:
|
2023-01-18 12:30:20 +00:00
|
|
|
alias regctl="/path/to/regctl"
|
2023-01-18 19:55:51 +00:00
|
|
|
|
|
|
|
|
2023-01-19 11:24:10 +00:00
|
|
|
dupc () {
|
2023-01-18 10:53:28 +00:00
|
|
|
if [[ -z "$1" ]]; then
|
|
|
|
echo "No container name given, here's the list of currently running containers:"
|
|
|
|
docker ps --format '{{.Names}}'
|
|
|
|
else
|
2023-01-19 08:58:06 +00:00
|
|
|
for i in $(docker ps --filter "name=$1" --format '{{.Names}}')
|
|
|
|
do
|
|
|
|
RepoUrl=$(docker inspect $i --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 for $i.\n" ; else printf "$i is already latest.\n" ; fi
|
|
|
|
done
|
2023-01-18 10:53:28 +00:00
|
|
|
fi
|
|
|
|
}
|