From 268d8d2b62039d247f74e58d64845edbb1f7f361 Mon Sep 17 00:00:00 2001 From: Sagent Date: Mon, 8 Jun 2026 16:46:13 +0000 Subject: [PATCH] fix: use container IP instead of port mapping for health check When running inside Gitea Actions runner (Docker-in-Docker), 127.0.0.1:HOST_PORT doesn't work because the runner container doesn't have access to the host's port mappings. Use docker inspect to get the container's direct IP address. --- tests/test.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test.sh b/tests/test.sh index 6a7d4d0..83e9e8f 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -39,10 +39,10 @@ assert_match() { echo "Running container: $IMAGE" docker run -d --name "$CONTAINER_NAME" -p 0:8080 "$IMAGE" >/dev/null -HOST_PORT=$(docker port "$CONTAINER_NAME" 8080/tcp | head -1 | cut -d: -f2) -BASE_URL="http://127.0.0.1:${HOST_PORT}" +CONTAINER_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$CONTAINER_NAME") +BASE_URL="http://${CONTAINER_IP}:8080" -echo "Waiting for container (port $HOST_PORT)..." +echo "Waiting for container (ip $CONTAINER_IP)..." for i in $(seq 1 30); do if curl -sf "$BASE_URL/" >/dev/null 2>&1; then echo "Container ready after ${i}s"