diff --git a/scripts/edge-gateway-e2e.mjs b/scripts/edge-gateway-e2e.mjs index 04c38393..e3eb0966 100644 --- a/scripts/edge-gateway-e2e.mjs +++ b/scripts/edge-gateway-e2e.mjs @@ -124,22 +124,29 @@ async function readComposeServiceHost(rootDir, composeProject, serviceName) { allowFailure: true, }); const containerId = String(ps.stdout || "").trim().split(/\s+/).find(Boolean); - if (!containerId) { - return null; + const containerRefs = [ + ...(containerId ? [containerId] : []), + serviceName, + ]; + + for (const containerRef of [...new Set(containerRefs)]) { + const inspection = await runCommand("docker", [ + "inspect", + "-f", + "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}", + containerRef, + ], { + cwd: rootDir, + allowFailure: true, + }); + const host = String(inspection.stdout || "").trim().split(/\s+/).find((value) => /^\d{1,3}(?:\.\d{1,3}){3}$/.test(value)); + + if (host) { + return host; + } } - const inspection = await runCommand("docker", [ - "inspect", - "-f", - "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}", - containerId, - ], { - cwd: rootDir, - allowFailure: true, - }); - const host = String(inspection.stdout || "").trim().split(/\s+/).find((value) => /^\d{1,3}(?:\.\d{1,3}){3}$/.test(value)); - - return host || null; + return null; } async function candidateApiBaseUrls(baseUrl, rootDir, composeProject) {