Files
mtusi2026lab3/scripts/stop-one.sh
2026-11-12 21:23:41 +03:00

15 lines
351 B
Bash
Executable File

#!/bin/sh
set -eu
: "${TARGET_INSTANCE_ID:?TARGET_INSTANCE_ID is required}"
for container in $(docker compose --env-file .env ps -q api); do
hostname=$(docker inspect --format '{{.Config.Hostname}}' "$container")
if [ "$hostname" = "$TARGET_INSTANCE_ID" ]; then
docker stop "$container" >/dev/null
exit 0
fi
done
exit 2