Docker complained about no container is there when calling the container
removal step without checking the existence of container.
In this change, action will be taken only if there is any container.
Change-Id: I32efc98bb4e2c2f5a47bffa88fc5c5b4c8e5d821
Signed-off-by: helenyao <yaohelan@huawei.com>
echo " Removing $FUNCTEST_IMAGE:<none> images and their containers..."
for image_id in "${dangling_images[@]}"; do
echo " Removing image_id: $image_id and its containers"
- docker ps -a | grep $image_id | awk '{print $1}'| xargs docker rm -f >${redirect}
+ containers=$(docker ps -a | grep $image_id | awk '{print $1}')
+ if [[ -n "$containers" ]];then
+ docker rm -f $containers >${redirect}
+ fi
docker rmi $image_id >${redirect}
done
fi