@echo off rem Stop exactly ONE API replica identified by TARGET_INSTANCE_ID. rem The container hostname is the X-Instance-Id value used by the API. setlocal enabledelayedexpansion cd /d "%~dp0.." if "%TARGET_INSTANCE_ID%"=="" ( echo TARGET_INSTANCE_ID is required 1>&2 exit /b 2 ) for /f %%i in ('docker compose --env-file .env ps -q api') do ( for /f %%h in ('docker inspect --format "{{.Config.Hostname}}" %%i') do ( if "%%h"=="%TARGET_INSTANCE_ID%" ( docker stop --time 1 %%i >nul exit /b 0 ) ) ) echo target API replica not found: %TARGET_INSTANCE_ID% 1>&2 exit /b 1