#!/usr/bin/env bash set -euo pipefail cd "$(dirname "$0")/.." : "${TARGET_INSTANCE_ID:?TARGET_INSTANCE_ID is required}" for container_id in $(docker compose ps -q api); do hostname=$(docker inspect --format '{{.Config.Hostname}}' "$container_id") if [[ "$hostname" == "$TARGET_INSTANCE_ID" ]]; then mkdir -p evidence printf '%s %s\n' "$(date -u +%FT%TZ)" "$TARGET_INSTANCE_ID" >> evidence/stopped-replicas.txt docker stop --time 6 "$container_id" >/dev/null exit 0 fi done printf 'No running API container matches TARGET_INSTANCE_ID.\n' >&2 exit 1