From 7db983d29d7be5f0d1886447aeacd53617ced880 Mon Sep 17 00:00:00 2001 From: casjay Date: Fri, 27 Nov 2026 07:23:40 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Register=20runners=20on=20the=20?= =?UTF-8?q?nested=20bridge=20gateway,=20not=20127.0.0.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - rootfs/usr/local/etc/docker/init.d/zz-act_runner.sh: RUNNER_IP_ADDRESS defaults to the nested dockerd bridge gateway (resolved at start, 127.0.0.1 only as fallback); job containers got http://127.0.0.1 as server URL and checkout failed --- .../local/etc/docker/init.d/zz-act_runner.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/rootfs/usr/local/etc/docker/init.d/zz-act_runner.sh b/rootfs/usr/local/etc/docker/init.d/zz-act_runner.sh index ce04748..8997e28 100755 --- a/rootfs/usr/local/etc/docker/init.d/zz-act_runner.sh +++ b/rootfs/usr/local/etc/docker/init.d/zz-act_runner.sh @@ -328,10 +328,20 @@ RUNNER_LABELS+="act_runner:docker://catthehacker/ubuntu:full-latest," RUNNER_LABELS+="ubuntu-latest:docker://catthehacker/ubuntu:full-latest" unset _HOST_ARCH _ARCH_LABEL # - - - - - - - - - - - - - - - - - - - - - - - - - -# act_runner registers against gitea in the same container/network namespace, so use -# loopback rather than the detected external IP4_ADDRESS (which can be transient/wrong -# under Docker-in-Docker networking and caused "no route to host" registration failures) -RUNNER_IP_ADDRESS="${RUNNER_IP_ADDRESS:-127.0.0.1}" +# The registered address is also what jobs get as their server URL. Jobs run in containers on +# the nested dockerd bridge, where 127.0.0.1 is the job container itself, so checkout fails with +# "Failed to connect to 127.0.0.1 port 80". Use the bridge gateway (same network namespace as +# the server, reachable from job containers); RUNNER_IP_ADDRESS overrides it +RUNNER_IP_ADDRESS="${RUNNER_IP_ADDRESS:-}" +__runner_bridge_ip() { + local ip="" tries=0 + while [ -z "$ip" ] && [ $tries -lt 15 ]; do + ip="$(docker network inspect bridge -f '{{(index .IPAM.Config 0).Gateway}}' 2>/dev/null)" + [ -n "$ip" ] || ip="$(ip -4 -o addr show docker0 2>/dev/null | awk '{sub(/\/.*/, "", $4); print $4; exit}')" + [ -n "$ip" ] || { tries=$((tries + 1)); sleep 2; } + done + echo "${ip:-127.0.0.1}" +} RUNNER_CONFIG_DEFAULT="${RUNNER_CONFIG_DEFAULT:-$CONF_DIR/default_config.yaml}" RUNNER_DEFAULT_HOME="${RUNNER_DEFAULT_HOME:-$CONF_DIR/gitea}" RUNNER_CONFIG_NAME="${RUNNER_CONFIG_NAME:-act_runner.yaml}" @@ -524,6 +534,7 @@ __post_execute() { # message to show at completion local postMessageEnd="Finished post commands for $SERVICE_NAME" export RUNNERS_START="${RUNNERS_START:-5}" RUNNER_LABELS RUNNERS_LOG_DIR="$LOG_DIR" + [ -n "$RUNNER_IP_ADDRESS" ] || RUNNER_IP_ADDRESS="$(__runner_bridge_ip)" export SERVER_ADDRESS="$RUNNER_IP_ADDRESS:$GITEA_PORT" SERVER_TOKEN="${RUNNER_AUTH_TOKEN:-$SYS_AUTH_TOKEN}" export RUNNER_CACHE_HOST RUNNER_CACHE_PORT export RUNNER_CACHE_SECRET="${RUNNER_CACHE_SECRET:-$(__gen_cache_secret)}"