diff --git a/bootstrap/sbin/rebuild_system_from_scratch.sh b/bootstrap/sbin/rebuild_system_from_scratch.sh
index ceefc1af0183c1a1b54f9bf02296afd40b0843d2..48ccf2ddac641e23239b88333d97b5202633cb99 100755
--- a/bootstrap/sbin/rebuild_system_from_scratch.sh
+++ b/bootstrap/sbin/rebuild_system_from_scratch.sh
@@ -49,7 +49,7 @@ function move_tango_dir_out_of_the_way()
 
 function remove_images()
 {
-    images="$(for i in $(docker images | egrep -v "REPOSITORY" | awk '{printf "%s:%s\n", $1, $2}'); do printf "%s " ${i}; done)"
+    images="$(for i in $(docker images -q); do printf "%s " ${i}; done)"
     if [ ${#images} -eq 0 ]; then
         echo -e "\tThere are no images to delete."
     else