Skip to content

Commit f8fb382

Browse files
fix(scripts): handle docker cleanup when no containers are running (#977)
The docker-cleanup.sh script failed when no containers were running because grep -v returned exit code 1 on empty input, causing the script to abort due to set -euo pipefail. Add || true to the volume detection pipeline so the script succeeds when there are no running containers (in_use_volumes will be empty, which is the correct behavior). Signed-off-by: Derek Carr <decarr@redhat.com>
1 parent bb5bdb4 commit f8fb382

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

scripts/docker-cleanup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ info "Removing unused volumes..."
217217
# Identify volumes in use by running containers
218218
in_use_volumes=$(ce ps -q 2>/dev/null \
219219
| xargs -r ce inspect --format '{{range .Mounts}}{{.Name}} {{end}}' 2>/dev/null \
220-
| tr ' ' '\n' | sort -u | grep -v '^$')
220+
| tr ' ' '\n' | sort -u | grep -v '^$' || true)
221221

222222
unused_volumes=()
223223
while read -r vol; do

0 commit comments

Comments
 (0)