From 000fe51fef6ec64103e4ad50dd1a5037efdeee27 Mon Sep 17 00:00:00 2001 From: Michael Stucki Date: Fri, 3 Apr 2015 20:29:37 +0200 Subject: [PATCH] After successful build, delete existing containers --- CHANGELOG.md | 1 + run.sh | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7d4841..22cfccd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased][unreleased] ### Fixed - Fix check if build is needed +- After successful build, delete existing containers ## [0.3.0] - 2015-03-31 ### Added diff --git a/run.sh b/run.sh index 84450ca..bc65a03 100755 --- a/run.sh +++ b/run.sh @@ -22,6 +22,12 @@ if [ $? -ne 0 ]; then elif [[ $FORCE_BUILD = 1 ]] || ! echo "$IMAGE_EXISTS" | grep -q "$TAG"; then echo "Building Docker image $REPOSITORY:$TAG..." docker build -t $REPOSITORY:$TAG . + + # After successful build, delete existing containers + IS_EXISTING=$(docker inspect -f '{{.Id}}' $CONTAINER 2>/dev/null) + if [[ -n "$IS_EXISTING" ]]; then + docker rm $CONTAINER + fi fi # With the given name $CONTAINER, reconnect to running container, start