diff --git a/tools/cleanup-containers b/tools/cleanup-containers index 7b0e8341e0..b94c5db1e3 100755 --- a/tools/cleanup-containers +++ b/tools/cleanup-containers @@ -1,3 +1,7 @@ #!/bin/bash - -docker rm $@ $(docker ps -a -q) +CONTAINERS=`docker ps -a -q` +if [[ -z "$CONTAINERS" ]]; then + echo "No containers to cleanup, exit now." + exit 0 +fi +docker rm $@ $CONTAINERS diff --git a/tools/cleanup-images b/tools/cleanup-images index c0b1db55c6..871afd1d1a 100755 --- a/tools/cleanup-images +++ b/tools/cleanup-images @@ -6,4 +6,9 @@ cd "$(dirname "$REAL_PATH")/.." . tools/validate-docker-execute -docker rmi $@ $(docker images -a -q) +IMAGES=`docker images -a -q` +if [[ -z "$IMAGES" ]]; then + echo "No images to cleanup, exit now." + exit 0 +fi +docker rmi $@ $IMAGES