2 [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
4 # Remove containers along with image opnfv/yardstick*:<none>
5 dangling_images=($(docker images -f "dangling=true" | grep opnfv/yardstick | awk '{print $3}'))
6 if [[ -n ${dangling_images} ]]; then
7 echo "Removing opnfv/yardstick:<none> images and their containers..."
8 for image_id in "${dangling_images[@]}"; do
9 echo " Removing image_id: $image_id and its containers"
10 containers=$(docker ps -a | grep $image_id | awk '{print $1}')
11 if [[ -n "$containers" ]];then
12 docker rm -f $containers >${redirect}
14 docker rmi $image_id >${redirect}
18 echo "Cleaning up docker containers/images..."
19 # Remove previous running containers if exist
20 if [[ ! -z $(docker ps -a | grep opnfv/yardstick) ]]; then
21 echo "Removing existing opnfv/yardstick containers..."
22 docker ps -a | grep opnfv/yardstick | awk '{print $1}' | xargs docker rm -f >$redirect
26 # Remove existing images if exist
27 if [[ ! -z $(docker images | grep opnfv/yardstick) ]]; then
28 echo "Docker images to remove:"
29 docker images | head -1 && docker images | grep opnfv/yardstick
30 image_tags=($(docker images | grep opnfv/yardstick | awk '{print $2}'))
31 for tag in "${image_tags[@]}"; do
32 echo "Removing docker image opnfv/yardstick:$tag..."
33 docker rmi opnfv/yardstick:$tag >$redirect