forked from mtusi2026/mtusi2026lab3
13 lines
431 B
Bash
Executable File
13 lines
431 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
: "${TARGET_INSTANCE_ID:?TARGET_INSTANCE_ID is required}"
|
|
case "$TARGET_INSTANCE_ID" in
|
|
*[!a-fA-F0-9]*|'') echo "Invalid instance id" >&2; exit 2 ;;
|
|
esac
|
|
service=$(docker inspect --format '{{ index .Config.Labels "com.docker.compose.service" }}' "$TARGET_INSTANCE_ID")
|
|
if [ "$service" != api ]; then
|
|
echo "Target is not a Compose API replica" >&2
|
|
exit 2
|
|
fi
|
|
docker stop -t 1 "$TARGET_INSTANCE_ID" >/dev/null
|