diff --git a/bin/lib/nim.js b/bin/lib/nim.js index f291a0967..c3b66d89a 100644 --- a/bin/lib/nim.js +++ b/bin/lib/nim.js @@ -198,7 +198,15 @@ function nimStatusByName(name) { let healthy = false; if (state === "running") { - const health = runCapture(`curl -sf http://localhost:8000/v1/models 2>/dev/null`, { + // Resolve the host port dynamically instead of assuming 8000. + // The container always listens on 8000 internally, but the host + // mapping is configurable via startNimContainer(... port). + const rawHostPort = runCapture( + `docker inspect --format '{{(index (index .NetworkSettings.Ports "8000/tcp") 0).HostPort}}' ${shellQuote(name)} 2>/dev/null`, + { ignoreError: true } + ); + const hostPort = /^\d+$/.test(rawHostPort) ? Number(rawHostPort) : 8000; + const health = runCapture(`curl -sf http://localhost:${hostPort}/v1/models 2>/dev/null`, { ignoreError: true, }); healthy = !!health;