refactor(compose): update container name lookup
- filter by both compose v1 and v2 naming conventions
This commit is contained in:
parent
389f5ef059
commit
bd36035a9f
@ -110,7 +110,7 @@ cleanup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
doDocker() {
|
doDocker() {
|
||||||
containerName="$(docker ps -a --format '{{ .Names }}' --filter name=${COMPOSE_PROJECT_NAME}_${2}-mailcow_1)"
|
containerName="$(docker ps -a --format '{{ .Names }}' --filter "name=${COMPOSE_PROJECT_NAME}_${2}-mailcow_1" --filter "name=${COMPOSE_PROJECT_NAME}-${2}-mailcow-1")"
|
||||||
|
|
||||||
# determine action to take
|
# determine action to take
|
||||||
if [ "$1" = "stop" ]; then
|
if [ "$1" = "stop" ]; then
|
||||||
@ -118,14 +118,14 @@ doDocker() {
|
|||||||
"$cyan" "$(stamp)" "$2" "$norm" >>"$logFile"
|
"$cyan" "$(stamp)" "$2" "$norm" >>"$logFile"
|
||||||
${dockerCmd} -f "$mcDockerCompose" stop --timeout "$dockerStopTimeout" "$2-mailcow" 2>>"$logFile"
|
${dockerCmd} -f "$mcDockerCompose" stop --timeout "$dockerStopTimeout" "$2-mailcow" 2>>"$logFile"
|
||||||
# set result vars
|
# set result vars
|
||||||
dockerResultState="$(docker inspect -f '{{ .State.Running }}' $containerName)"
|
dockerResultState="$(docker inspect -f '{{ .State.Running }}' "$containerName")"
|
||||||
dockerResultExit="$(docker inspect -f '{{ .State.ExitCode }}' $containerName)"
|
dockerResultExit="$(docker inspect -f '{{ .State.ExitCode }}' "$containerName")"
|
||||||
elif [ "$1" = "start" ]; then
|
elif [ "$1" = "start" ]; then
|
||||||
printf "%s[%s] -- [INFO] Starting %s-mailcow container --%s\n" \
|
printf "%s[%s] -- [INFO] Starting %s-mailcow container --%s\n" \
|
||||||
"$cyan" "$(stamp)" "$2" "$norm" >>"$logFile"
|
"$cyan" "$(stamp)" "$2" "$norm" >>"$logFile"
|
||||||
${dockerCmd} -f "$mcDockerCompose" start "$2-mailcow" 2>>"$logFile"
|
${dockerCmd} -f "$mcDockerCompose" start "$2-mailcow" 2>>"$logFile"
|
||||||
# set result vars
|
# set result vars
|
||||||
dockerResultState="$(docker inspect -f '{{ .State.Running }}' $containerName)"
|
dockerResultState="$(docker inspect -f '{{ .State.Running }}' "$containerName")"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user