From bf4856fa53fb4787315d7f7d3d5335243f954ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaak=20K=C3=BCtt?= Date: Mon, 10 Aug 2015 15:32:54 +0300 Subject: [PATCH] Fix grep difference bug in excluding containers Function compute_exclude_container_ids introduced with pull request #38 did not take into account that the docker-gc container built from the Dockerfile included a lightweight Linux distribution with a lighter version of grep which failed if multiple docker container names were specified. Modified the function to make use of the extended regex flag. --- docker-gc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-gc b/docker-gc index 5e69685..ba7443a 100755 --- a/docker-gc +++ b/docker-gc @@ -110,12 +110,12 @@ function compute_exclude_container_ids() { # Implode their values with a \| separator on a single line PROCESSED_EXCLUDES=`cat $EXCLUDE_CONTAINERS_FROM_GC \ | xargs \ - | sed -e 's/ /\\\|/g'` + | sed -e 's/ /\|/g'` # Find all docker images # Filter out with matching names # and put them to $EXCLUDE_CONTAINER_IDS_FILE $DOCKER ps -a \ - | grep "$PROCESSED_EXCLUDES" \ + | grep -E "$PROCESSED_EXCLUDES" \ | awk '{ print $1 }' \ | tr -s " " "\012" \ | sort -u > $EXCLUDE_CONTAINER_IDS_FILE