From b973b7060d4cadbf54b6c4bac4f28c69bbf5cdab Mon Sep 17 00:00:00 2001 From: Conor Heine <1045603+cahna@users.noreply.github.com> Date: Sun, 5 Apr 2026 14:00:55 -0700 Subject: [PATCH] fix: fall back to Docker bridge IP when host.docker.internal is unresolvable (#216) On native Linux Docker, host.docker.internal doesn't exist (only Docker Desktop provides it). Detect this and use the bridge IP (172.17.0.1) instead, so Lambda containers can reach the Runtime API without manual configuration. --- .../lambda/launcher/DockerHostResolver.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/hectorvent/floci/services/lambda/launcher/DockerHostResolver.java b/src/main/java/io/github/hectorvent/floci/services/lambda/launcher/DockerHostResolver.java index 940eb5154d..338d0c67ed 100644 --- a/src/main/java/io/github/hectorvent/floci/services/lambda/launcher/DockerHostResolver.java +++ b/src/main/java/io/github/hectorvent/floci/services/lambda/launcher/DockerHostResolver.java @@ -53,8 +53,15 @@ public class DockerHostResolver { } } - LOG.debugv("Using host.docker.internal for container-to-host communication"); - return HOST_DOCKER_INTERNAL; + // On Docker Desktop (macOS/Windows/Linux Desktop), host.docker.internal works. + // On native Linux Docker, it doesn't exist - fall back to bridge IP. + if (isHostDockerInternalResolvable()) { + LOG.debugv("Using host.docker.internal for container-to-host communication"); + return HOST_DOCKER_INTERNAL; + } + + LOG.infov("host.docker.internal not resolvable (native Linux Docker?) — using bridge IP: {0}", LINUX_DOCKER_BRIDGE); + return LINUX_DOCKER_BRIDGE; } private boolean isRunningInContainer() { @@ -69,4 +76,13 @@ public class DockerHostResolver { return false; } } + + private boolean isHostDockerInternalResolvable() { + try { + InetAddress.getByName(HOST_DOCKER_INTERNAL); + return true; + } catch (Exception e) { + return false; + } + } }