From 32c08a8dd4f50fe3768986d73e957986d12a9aa4 Mon Sep 17 00:00:00 2001 From: Scott Little Date: Fri, 14 Dec 2018 10:35:30 -0500 Subject: [PATCH] build-stx-base.sh --latest --clean fails to clean the latest image When both --latest and --clean flags are passed to build-stx-base.sh we expect the docker image tagged as '...-latest' to be deleted from the local build environment. This did not occure ... starlingx/stx-centos dev-latest 279c713e0b5d 7 hours ago 331MB starlingx/stx-centos dda342637517 19 hours ago 331MB Adding a code block to handle the case when these flags are combined. Closes-Bug: 1808544 Change-Id: Ic2d17bc285f3746965c2a5e7ec49c278f0fbf066 Signed-off-by: Scott Little --- build-tools/build-docker-images/build-stx-base.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/build-tools/build-docker-images/build-stx-base.sh b/build-tools/build-docker-images/build-stx-base.sh index 6ba1cb1b..67ad57cc 100755 --- a/build-tools/build-docker-images/build-stx-base.sh +++ b/build-tools/build-docker-images/build-stx-base.sh @@ -249,6 +249,15 @@ if [ "${CLEAN}" = "yes" ]; then exit 1 fi + if [ "$TAG_LATEST" = "yes" ]; then + echo "Deleting image: ${IMAGE_NAME_LATEST}" + docker image rm ${IMAGE_NAME_LATEST} + if [ $? -ne 0 ]; then + echo "Failed running docker image rm command" >&2 + exit 1 + fi + fi + if [ ${BASE_IMAGE_PRESENT} -ne 0 ]; then # The base image was not already present, so delete it echo "Removing docker image ${OS}:${OS_VERSION}"