3
# Destructive action - Destroys images on the host that are not running
5
untagged=$(action-get untagged)
6
images=$(docker images | grep "^<none>" | awk "{print $3}")
7
all_images=$(docker images -aq)
9
if [[ ! -z "$images" && "$untagged" == "True" ]]; then
10
echo "Removing untagged images"
15
if [[ ! -z "$all_images" && "$untagged" ]]; then
16
echo "Removing all non-running images"
17
$(docker rmi $all_images)
20
echo "Not all containers removed, perhaps you need to juju action do $JUJU_UNIT_NAME clean-containers first?"
21
action-set response.msg="Not all containers removed, perhaps you need to juju action do $JUJU_UNIT_NAME clean-containers first?"
22
action-set response.result=$(docker rmi $all_images)