From ca9b569bfdd3527f6d1273a6b6f854f54c02fb41 Mon Sep 17 00:00:00 2001 From: t3chn0m4g3 Date: Wed, 21 Nov 2018 13:44:13 +0000 Subject: [PATCH] update script need to take care of prev. version images --- update.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/update.sh b/update.sh index 76ae79a6..6bdbdc4d 100755 --- a/update.sh +++ b/update.sh @@ -145,6 +145,17 @@ fi echo } +# Remove old images for specific tag +function fuREMOVEOLDIMAGES () { +local myOLDTAG=$1 +local myOLDIMAGES=$(docker images | grep -c "$myOLDTAG") +if [ "$myOLDIMAGES" -gt "0" ]; + then + echo "### Removing old docker images." + docker rmi $(docker images | grep "$myOLDTAG" | awk '{print $3}') +fi +} + # Let's load docker images in parallel function fuPULLIMAGES { local myTPOTCOMPOSE="/opt/tpot/etc/tpot.yml" @@ -187,6 +198,7 @@ echo "### Now pulling latest docker images" echo "######$myBLUE This might take a while, please be patient!$myWHITE" fuPULLIMAGES 2>&1>/dev/null +fuREMOVEOLDIMAGES "1804" echo "### If you made changes to tpot.yml please ensure to add them again." echo "### We stored the previous version as backup in /root/." echo "### Done, please reboot."