@echo off setlocal cd /d "%~dp0.." if "%TARGET_INSTANCE_ID%"=="" ( echo TARGET_INSTANCE_ID is required 1>&2 exit /b 2 ) set TARGET_STOPPED= for /f "delims=" %%i in ('docker compose ps -q api') do if not defined TARGET_STOPPED call :stop_if_target %%i if defined TARGET_STOPPED exit /b 0 echo No running API replica matches TARGET_INSTANCE_ID 1>&2 exit /b 1 :stop_if_target for /f "delims=" %%h in ('docker inspect --format "{{.Config.Hostname}}" %1') do if "%%h"=="%TARGET_INSTANCE_ID%" ( docker stop --time 2 %1 >nul if errorlevel 1 exit /b 1 set TARGET_STOPPED=1 exit /b 0 ) exit /b 1