2023-01-18 10:54:03 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-01-23 11:05:22 +00:00
|
|
|
### Requires the regctl binary.
|
2023-01-18 10:53:28 +00:00
|
|
|
### Get it here: https://github.com/regclient/regclient/releases
|
|
|
|
|
2023-01-18 19:55:51 +00:00
|
|
|
### Preferably placed in .bashrc or similar
|
|
|
|
|
2023-01-23 11:05:22 +00:00
|
|
|
### Set the full path to the binary or just regctl if in PATH:
|
|
|
|
regctl="/home/gw-tdc/dockers/regctl"
|
2023-01-18 19:55:51 +00:00
|
|
|
|
2023-01-19 11:24:10 +00:00
|
|
|
dupc () {
|
2023-01-23 11:05:22 +00:00
|
|
|
if [[ "$@" == "help" ]]; then
|
2023-01-18 10:53:28 +00:00
|
|
|
echo "No container name given, here's the list of currently running containers:"
|
|
|
|
docker ps --format '{{.Names}}'
|
|
|
|
else
|
2023-01-23 11:05:22 +00:00
|
|
|
for i in $(docker ps --filter "name=$@" --format '{{.Names}}')
|
2023-01-19 08:58:06 +00:00
|
|
|
do
|
|
|
|
RepoUrl=$(docker inspect $i --format='{{.Config.Image}}')
|
2023-01-23 11:05:22 +00:00
|
|
|
LocalHash=$(docker image inspect $RepoUrl --format '{{.RepoDigests}}')
|
|
|
|
RegHash=$($regctl image digest --list $RepoUrl 2>/dev/null)
|
|
|
|
if [ $? -eq 0 ] ; then
|
|
|
|
if [[ "$LocalHash" = *"$RegHash"* ]] ; then printf "$i is already latest.\n" ; else printf "$i got updates.\n" ; fi
|
|
|
|
else
|
|
|
|
printf "$i got errors, no check possible.\n"
|
|
|
|
fi
|
2023-01-19 08:58:06 +00:00
|
|
|
done
|
2023-01-18 10:53:28 +00:00
|
|
|
fi
|
|
|
|
}
|
2023-01-23 11:05:22 +00:00
|
|
|
dupc $1
|