diff options
author | jose.lausuch <jose.lausuch@ericsson.com> | 2015-12-27 16:55:15 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@172.30.200.206> | 2015-12-27 16:55:16 +0000 |
commit | ac6c03ac31cf4362c6f277858d8f62ccd93439c5 (patch) | |
tree | 02dd930c4d5ed5d2264d4a5e9e6c53a3a28df399 /jjb | |
parent | 0b186f15e1dfc3c6dcb9e2760f37666b5ae1dc49 (diff) | |
parent | 26dcece49100f626a4646c6525aea78ef115518b (diff) |
Merge "Wait for containers to be removed before removing images"
Diffstat (limited to 'jjb')
-rw-r--r-- | jjb/opnfv/opnfv-docker.sh | 18 |
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 |