Race condition (?) when the runner starts

I run gitea (1.23.7) and the runner (v0.2.11+15-gb1ae30d) in docker, started from a single compose file:

networks:
  default:
    external: true
    name: proxy
services:
  gitea:
    image: gitea/gitea:latest
    labels:
      - traefik.enable=true
      - traefik.http.routers.gitea.rule=Host(`gitea.XXX`)
      - traefik.http.services.gitea.loadbalancer.server.port=3000
      - tsdproxy.enable=true
    restart: unless-stopped
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - gitea:/data
  runner:
    image: docker.io/gitea/act_runner:nightly
    environment:
      # CONFIG_FILE: /config.yaml
      GITEA_INSTANCE_URL: http://gitea
      GITEA_RUNNER_REGISTRATION_TOKEN: XXX
      GITEA_RUNNER_NAME: runner01
    volumes:
      - runner:/data
      - /var/run/docker.sock:/var/run/docker.sock
    depends_on:
      - gitea
volumes:
  gitea: null
  runner: null

When starting the compose file, the runner always fails with

runner-1  | time="2025-04-25T10:31:06Z" level=info msg="Starting runner daemon"
gitea-1   | 2025/04/25 12:31:06 cmd/web.go:253:runWeb() [I] Starting Gitea on PID: 18
runner-1  | time="2025-04-25T10:31:06Z" level=error msg="Your Gitea version is too old to support runner declare, please upgrade to v1.21 or later"
runner-1  | Error: unimplemented: 404 Not Found

The error is incorrect, Gitea is 1.23+.

When I now start the runner (gitea is running for some time), it starts fine and everything works as expected.

There seems to be some kind of “race condition” (not really this, but you get the idea) when the runner is started too quickly (?) compared to Gitea (and the message does not make sense - it look like the runner did manage to connect to Gitea after all)

Gitea takes a bit of time to start however it looks ok for docker-compose since process is running. Try adding healthcheck to your manifest