diff --git a/dockcheck.sh b/dockcheck.sh index a943765..9a4b4be 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -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 -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