aboutsummaryrefslogtreecommitdiff
path: root/tools/cleanup-images
blob: 1e6983f577ba9c607fb61256cbae1788e90e9d19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/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