forked from mtusi2026/mtusi2026lab5
20 lines
545 B
Bash
Executable File
20 lines
545 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
: "${TARGET_INSTANCE_ID:?test provides target API instance alias}"
|
|
|
|
found=
|
|
for container_id in $(docker compose ps --quiet --status running api); do
|
|
hostname=$(docker inspect --format '{{.Config.Hostname}}' "$container_id")
|
|
if [ "$hostname" = "$TARGET_INSTANCE_ID" ]; then
|
|
found=$container_id
|
|
break
|
|
fi
|
|
done
|
|
|
|
if [ -z "$found" ]; then
|
|
printf '%s\n' 'No running API container matched the requested instance alias.' >&2
|
|
exit 1
|
|
fi
|
|
docker stop --time 5 "$found" >/dev/null
|