I have a script that I run to update images and then stop
-> rm
-> run
them again. Unfortunately, the last 3 steps happen even if pull
didn't update the image (i.e. it's already up to date). How can I change my bash script so that it only runs the last 3 commands if the pull updated the image?
#!/usr/bin/env bash
set -e
docker pull linuxserver/sonarr
docker stop sonarr
docker rm sonarr
./run-sonarr.sh
docker pull linuxserver/radarr
docker stop radarr
docker rm radarr
./run-radarr.sh
docker pull linuxserver/nzbget
docker stop nzbget
docker rm nzbget
./run-nzbget.sh
docker pull plexinc/pms-docker
docker stop plex
docker rm plex
./run-plex.sh
You can just check if the string "Image is up to date" is not present:
You can get the image IDs before and after the pull and compare them:
For instance: