changed the RepoDigests grab and logic

This commit is contained in:
mag37 2025-12-06 16:56:23 +01:00
parent 7493d462b3
commit c931b16eab

View file

@ -571,7 +571,9 @@ if [[ -n "${GotUpdates:-}" ]]; then
# Add new backup tag prior to pulling if option is set
if [[ -n "${DaysKept:-}" ]]; then
ContRepoDigests=$(docker image inspect "$ImageId" --format "{{index .RepoDigests 0}}")
ImageConfig=$(docker image inspect "$ImageId" --format '{{ json . }}')
ContRepoDigests=$($jqbin -r '.RepoDigests[0]' <<< "$ImageConfig")
[[ "$ContRepoDigests" == "null" ]] && ContRepoDigests=""
ContRepo=${ContImage%:*}
ContApp=${ContRepo#*/}
[[ "$ContImage" =~ ":" ]] && ContTag=${ContImage#*:} || ContTag="latest"
@ -593,7 +595,7 @@ if [[ -n "${GotUpdates:-}" ]]; then
if docker pull "$ContImage"; then
# Removal of the <none>-tag image left behind from backup
[[ -n "${DaysKept:-}" ]] && docker rmi "$ContRepoDigests"
if [[ ! -z "${ContRepoDigests:-}" ]] && [[ -n "${DaysKept:-}" ]]; then docker rmi "$ContRepoDigests"; fi
else
printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1
fi