Files
mtusi2026lab3/scripts/stop-one.sh
T

21 lines
427 B
Bash

#!/bin/sh
set -eu
if [ -z "${TARGET_INSTANCE_ID:-}" ]; then
echo "TARGET_INSTANCE_ID is required"
exit 1
fi
for container in $(docker compose ps -q --all api); do
instance_id=$(docker inspect --format '{{.Config.Hostname}}' "$container")
if [ "$instance_id" = "$TARGET_INSTANCE_ID" ]; then
docker stop --time 2 "$container" >/dev/null
exit 0
fi
done
echo "API replica not found"
exit 1