summaryrefslogtreecommitdiffstats
path: root/jjb/opnfv
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2016-01-18 14:15:36 +0100
committerjose.lausuch <jose.lausuch@ericsson.com>2016-01-18 14:22:59 +0100
commit2fdfcb23dd11c2bf4b8e49c4c992563088857a5c (patch)
treea4755f96f0d73b18fdf734c94068e4cb873d7d7e /jjb/opnfv
parent6544d0ae3a7e409a1f8b6be23ce3d5c67e9607f2 (diff)
test: Add more consistency when cleaning docker containers/images
Change-Id: I085ca47e4e487d93c700c3e729b8b86b2b7abde1 Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'jjb/opnfv')
-rw-r--r--jjb/opnfv/opnfv-docker.sh17
1 files changed, 7 insertions, 10 deletions
diff --git a/jjb/opnfv/opnfv-docker.sh b/jjb/opnfv/opnfv-docker.sh
index 108485d0b..bf355973c 100644
--- a/jjb/opnfv/opnfv-docker.sh
+++ b/jjb/opnfv/opnfv-docker.sh
@@ -10,17 +10,12 @@ echo
# Remove previous running containers if exist
-if [[ ! -z $(docker ps -a | grep $DOCKER_REPO_NAME) ]]; then
+if [[ -n "$(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 -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
+ while [[ $t -gt 0 ]] && [[ -n "$(docker ps| grep $DOCKER_REPO_NAME)" ]]; do
sleep 1
let t=t-1
done
@@ -28,13 +23,15 @@ fi
# Remove existing images if exist
-if [[ ! -z $(docker images | grep $DOCKER_REPO_NAME) ]]; then
+if [[ -n "$(docker images | grep $DOCKER_REPO_NAME)" ]]; then
echo "Docker images to remove:"
docker images | head -1 && docker images | grep $DOCKER_REPO_NAME
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 -f $DOCKER_REPO_NAME:$tag
+ if [[ -n "$(docker images|grep $DOCKER_REPO_NAME|grep $tag)" ]]; then
+ echo "Removing docker image $DOCKER_REPO_NAME:$tag..."
+ docker rmi -f $DOCKER_REPO_NAME:$tag
+ fi
done
fi