Cloudflare’s cloudflared container doesn’t come with a good health check – or so it seems [1]. The functionality is there, though. The tunnel needs to be started with metrics enabled (here: exposed to 127.0.0.1:20241) and the health check needs to call the proper check.
cloudflared:
image: cloudflare/cloudflared:latest
...
command: tunnel --metrics 127.0.0.1:20241 run
healthcheck:
test: ["CMD","cloudflared","tunnel","--metrics","127.0.0.1:20241","ready"]
...