summaryrefslogtreecommitdiffstats
path: root/jjb/opnfv
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2015-12-26 21:55:45 +0100
committerjose.lausuch <jose.lausuch@ericsson.com>2015-12-27 17:52:49 +0100
commit26dcece49100f626a4646c6525aea78ef115518b (patch)
tree5b4ed381ae483f6831cb2f49f105b6641fd7d1ee /jjb/opnfv
parentaf114946985ea7a93f87f4ed3a21c28a74d43d1d (diff)
Wait for containers to be removed before removing images
This will avoid some errors like this: "Error response from daemon: conflict: unable to delete 44c2887519de (must be forced) - image is being used by stopped container 7dbed6d40e5a" Change-Id: I54b8b76fbcc6f208ab52c88b43ea18af935e69c7 Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'jjb/opnfv')
-rw-r--r--jjb/opnfv/opnfv-docker.sh18
1 files changed, 14 insertions, 4 deletions
diff --git a/jjb/opnfv/opnfv-docker.sh b/jjb/opnfv/opnfv-docker.sh
index 6f0a0c35c..d65603fec 100644
--- a/jjb/opnfv/opnfv-docker.sh
+++ b/jjb/opnfv/opnfv-docker.sh
@@ -12,8 +12,18 @@ echo
# Remove previous running containers if exist
if [[ ! -z $(docker ps -a | grep $DOCKER_REPO_NAME) ]]; then
echo "Removing existing $DOCKER_REPO_NAME containers..."
- docker ps | grep $DOCKER_REPO_NAME | awk '{{print $1}}' | xargs docker stop
- docker ps -a | grep $DOCKER_REPO_NAME | awk '{{print $1}}' | xargs docker rm
+ #docker ps | grep $DOCKER_REPO_NAME | awk '{{print $1}}' | xargs docker stop
+ docker ps -a | grep $DOCKER_REPO_NAME | awk '{{print $1}}' | xargs docker rm -f
+ t=60
+ # Wait max 60 sec for containers to be removed
+ while [ $t -gt 0 ]; do
+ ids=$(docker ps | grep $DOCKER_REPO_NAME |awk '{{print $1}}')
+ if [[ -z $ids ]]; then
+ break
+ fi
+ sleep 1
+ let t=t-1
+ done
fi
@@ -24,7 +34,7 @@ if [[ ! -z $(docker images | grep $DOCKER_REPO_NAME) ]]; then
image_tags=($(docker images | grep $DOCKER_REPO_NAME | awk '{{print $2}}'))
for tag in "${{image_tags[@]}}"; do
echo "Removing docker image $DOCKER_REPO_NAME:$tag..."
- docker rmi $DOCKER_REPO_NAME:$tag
+ docker rmi -f $DOCKER_REPO_NAME:$tag
done
fi
@@ -36,7 +46,7 @@ if [[ "$UPDATE_LATEST_STABLE" == "true" ]]; then
echo "ERROR: The image $DOCKER_REPO_NAME with tag $STABLE_TAG does not exist."
exit 1
fi
- docker tag $DOCKER_REPO_NAME:$STABLE_TAG $DOCKER_REPO_NAME:latest_stable
+ docker tag -f $DOCKER_REPO_NAME:$STABLE_TAG $DOCKER_REPO_NAME:latest_stable
echo "Pushing $DOCKER_REPO_NAME:latest_stable ..."
docker push $DOCKER_REPO_NAME:latest_stable
exit 0