Files
mtusi2026lab7/scripts/stop-one.sh
T
kaktuz20000 5a6fcff3ef
Skeleton contracts / contracts (pull_request) Canceled after 0s
выполение на 5
2026-11-04 19:22:35 +03:00

21 lines
578 B
Bash
Executable File

#!/bin/sh
set -eu
: "${TARGET_INSTANCE_ID:?test provides target API instance alias}"
matches=0
target_container=
for container in $(docker compose --env-file .env ps -q api); do
hostname=$(docker inspect --format '{{.Config.Hostname}}' "$container")
if [ "$hostname" = "$TARGET_INSTANCE_ID" ]; then
matches=$((matches + 1))
target_container=$container
fi
done
if [ "$matches" -ne 1 ]; then
printf '%s\n' 'Could not resolve TARGET_INSTANCE_ID to exactly one API container.' >&2
exit 1
fi
docker stop --time 2 "$target_container" >/dev/null