From 8c7597f546b5dd313158253fe673e2cb5b52a182 Mon Sep 17 00:00:00 2001 From: Casper Date: Fri, 12 Jun 2020 01:33:30 +0200 Subject: [PATCH] Improve container/image name detection Problem: `setup.sh` fails, if more than one container uses `CMD ["supervisord", "-c", "/etc/supervisor/supervisord.conf"]` Current container/image name detection: List all containers, grep for "supervisor". New approach: List container, with label `org.label-schema.name="docker-mailserver"` --- setup.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/setup.sh b/setup.sh index 029813ec..6913e86e 100755 --- a/setup.sh +++ b/setup.sh @@ -25,13 +25,10 @@ if [ -z "$CRI" ]; then fi fi -INFO=$($CRI ps \ - --no-trunc \ - --format="{{.Image}} {{.Names}} {{.Command}}" | \ - grep "supervisord -c /etc/supervisor/supervisord.conf") +INFO=$($CRI ps --no-trunc --format "{{.Image}};{{.Names}}" --filter label=org.label-schema.name="docker-mailserver") -IMAGE_NAME=$(echo $INFO | awk '{print $1}') -CONTAINER_NAME=$(echo $INFO | awk '{print $2}') +IMAGE_NAME=${INFO%;*} +CONTAINER_NAME=${INFO#*;} DEFAULT_CONFIG_PATH="$(pwd)/config" USE_CONTAINER=false