summaryrefslogtreecommitdiff
path: root/tcwg-cleanup-stale-containers.sh
diff options
context:
space:
mode:
authorMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2018-06-01 14:16:32 +0000
committerMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2018-06-05 07:48:03 +0000
commit064ebd6fc83c94c8a0cab6b1e1af89706d7fb000 (patch)
tree6948d2dc8a3e559e715512c4fb7cff3bcebe4a72 /tcwg-cleanup-stale-containers.sh
parent2e4e25441ec5c06c8f27b2901620e6107714be5b (diff)
tcwg-cleanup-stale-containers.sh: Avoid cleaning up named volumes.
We now start to keep useful data in docker volumes named host-home, home-$USER, etc. Change-Id: I4df6355de4fca9bcdc3073edefb8a6be4d97a61c
Diffstat (limited to 'tcwg-cleanup-stale-containers.sh')
-rwxr-xr-xtcwg-cleanup-stale-containers.sh9
1 files changed, 7 insertions, 2 deletions
diff --git a/tcwg-cleanup-stale-containers.sh b/tcwg-cleanup-stale-containers.sh
index c4220733..6515e9e0 100755
--- a/tcwg-cleanup-stale-containers.sh
+++ b/tcwg-cleanup-stale-containers.sh
@@ -133,10 +133,15 @@ do_cleanup_containers $cleanup_stopped_hours "-a" "rm -fv" &
wait $! || res=$?
status=$(($status|(2*$res)))
-if [ x"$($DOCKER volume ls -q -f dangling=true)" != x"" ]; then
+rm_volumes=($($DOCKER volume ls -q -f dangling=true))
+# Filter-out named volumes like host-home and home-$USER. Leave only volumes
+# named like a sha1 hash.
+rm_volumes=($(echo "${rm_volumes[@]}" | grep "^[a-f0-9]\{64\}\$"))
+
+if [ ${#rm_volumes[@]} != 0 ]; then
echo "Removing dangling volumes"
if $cleanup_volumes; then
- for volume in $($DOCKER volume ls -q -f dangling=true); do
+ for volume in "${rm_volumes[@]}"; do
$DOCKER volume rm $volume &
res=0; wait $! || res=$?
if [ $res != 0 ]; then