Guide

Run a heartbeat sender with Docker Compose

A small container can send periodic HTTPS requests from your Docker host. Use it to observe the container’s ability to run and reach the internet.

Be clear about which container is reporting

This example runs a dedicated curl container. It can stay Online even if a database, website or Home Assistant container next to it has failed. A running heartbeat container is not a health check of the whole Compose project.

For application monitoring, send only after the application’s own check succeeds, from the application or a checker that actually observes it. For Home Assistant, prefer the automation inside Core.

Configure the URL and interval

  1. Create an account, then add a device with a name you will recognize in an alert.
  2. Choose and save the heartbeat interval and alert delay. These examples use 60 seconds between requests; match your sender to the saved settings. The alert delay must be at least twice the heartbeat interval and leave room for network delays.
  3. Open Heartbeat setup on the device. The dashboard provides commands with your URL and selected interval already filled in.

Replace YOUR_DEVICE_KEY with the value after v= in your device’s heartbeat URL, including the account and device identifiers. The TurnIt endpoint is already filled in. Keep your personal URL private.

You need Docker with Compose available. The example waits 60 seconds after each request and uses a five-second request timeout. If you select another device interval, use the generated Compose example in the dashboard.

Save this as compose.yaml and run docker compose up -d. This check reports connectivity from the heartbeat container.

compose.yaml
services:
  turnit-heartbeat:
    image: curlimages/curl:8.23.0
    restart: unless-stopped
    environment:
      TURNIT_HEARTBEAT_URL: "https://api.turnit.app/api/send?v=YOUR_DEVICE_KEY"
    entrypoint: ["/bin/sh", "-c"]
    command:
      - |
        while :; do
          curl --fail --silent --show-error --max-time 5 "$$TURNIT_HEARTBEAT_URL" >/dev/null
          sleep 60
        done
Start the heartbeat service
docker compose up -d turnit-heartbeat

Understand Compose interpolation and restart behavior

The doubled dollar sign in $$TURNIT_HEARTBEAT_URL preserves the variable for the shell inside the container. It prevents Compose from replacing it with a variable from the host. Keep this spelling when copying the example.

The restart policy asks Docker to bring the sender back after an unexpected exit or daemon restart, unless you stopped it. Docker itself still needs to be running. A sleeping Docker Desktop host or a powered-off server cannot send heartbeats.

Inspect sender logs
docker compose logs --tail=50 turnit-heartbeat

Check Last heartbeat after starting. A 429 response suggests an interval mismatch or duplicate sender. This simple loop does not parse Retry-After; keep the saved interval aligned and leave margin in the alert delay.

Update or stop this service

After saving new timing settings, update the Compose file and rerun the start command to recreate the service. To stop it, target only the heartbeat service rather than bringing down the whole project.

Stop the heartbeat sender
docker compose stop turnit-heartbeat

Reference: Docker Compose variable interpolation.

Give your device a way to check in

Create a device to get your own heartbeat URL and setup instructions.