#!/bin/sh set -eu cd "$(dirname "$0")/.." : "${TARGET_INSTANCE_ID:?test provides instance alias}" # Default Docker hostname is the container's short ID, used as X-Instance-Id. for id in $(docker compose ps -q api); do hostname=$(docker inspect --format '{{.Config.Hostname}}' "$id") if [ "$hostname" = "$TARGET_INSTANCE_ID" ]; then docker stop --time 2 "$id" >/dev/null exit 0 fi done printf '%s\n' 'No running API container matches TARGET_INSTANCE_ID' >&2 exit 1