kolla/tools/cleanup-images
Dincer Celik e21a142111 Make tools bash compatible
Change-Id: Iccccc91b0a44f92bcbb2442638a93e7624da112b
2020-01-20 18:14:38 +03:00

21 lines
519 B
Bash
Executable File

#!/bin/bash
# Move to top level directory
REAL_PATH=$(realpath $0)
cd "$(dirname "$REAL_PATH")/.."
. tools/validate-docker-execute.sh
if [ -n "$1" ]; then
KOLLA_IMAGES=$(docker images -a --filter "label=kolla_version" --format "{{.Repository}}\t{{.ID}}" | grep -E "$1" | awk '{print$2}')
else
KOLLA_IMAGES=$(docker images -a --filter "label=kolla_version" --format "{{.ID}}")
fi
if [[ -z "$KOLLA_IMAGES" ]]; then
echo "No images to cleanup, exit now."
exit 0
else
docker rmi -f $KOLLA_IMAGES
fi