No description
  • Python 96.1%
  • Dockerfile 3.9%
Find a file
2026-03-30 15:55:18 +11:00
.github/workflows Initial commit 2026-03-29 15:37:45 +11:00
.env.example Revert "Token auth" 2026-03-29 21:47:19 +11:00
.gitignore Initial commit 2026-03-29 15:37:45 +11:00
COPYRIGHT copyright 2026-03-29 20:25:45 +11:00
Dockerfile Health check 2026-03-29 19:48:54 +11:00
healthcheck.py copyright 2026-03-29 20:24:05 +11:00
image.png Initial commit 2026-03-29 15:37:45 +11:00
LICENSE Health check 2026-03-29 19:48:54 +11:00
monitor.py Login retry 2026-03-30 15:55:18 +11:00
README.md Login retry 2026-03-30 15:55:18 +11:00
requirements.txt Health check 2026-03-29 19:48:54 +11:00

Kuma Container Sync

Auto-discovers Docker containers on a host and reconciles Uptime Kuma Docker monitors for them, organizing monitors under a host-named group and optionally attaching an existing notification.

Screenshot of Uptime Kuma with auto-generated Docker monitors

Features

  • Discover Docker containers via the Docker socket.
  • Create Uptime Kuma Docker monitors for new containers.
  • Keep existing monitors grouped under a host-specific monitor group.
  • Optionally attach an existing Uptime Kuma notification by name.
  • Reconcile periodically using SYNC_INTERVAL (idempotent loop).

Requirements

  • Uptime Kuma instance reachable at KUMA_URL with a user that can create/edit monitors.
  • A Docker Host configured in Uptime Kuma matching DOCKER_HOST_NAME.
  • Access to the Docker socket on the host (e.g., /var/run/docker.sock).

Environment Variables

  • KUMA_URL (default: http://uptime-kuma:3001): Base URL of your Uptime Kuma instance.
  • KUMA_USER (required): Uptime Kuma username.
  • KUMA_PASS (required): Uptime Kuma password.
  • DOCKER_HOST_NAME (required): Name of the Docker Host entry in Uptime Kuma to associate container monitors with.
  • KUMA_GROUP_NAME (default: value of DOCKER_HOST_NAME): Monitor group name to place all container monitors under.
  • NOTIFICATION_NAME (optional): Name of an existing Uptime Kuma notification to attach to created monitors. If not found or not provided, monitors are created without notifications.
  • SYNC_INTERVAL (default: 300): Seconds to wait between sync runs.
  • LOGIN_RETRIES (default: 5): Number of retry attempts for logging into Uptime Kuma.

See monitor.py for details.

Quick Start (Docker)

Build the image:

docker build -t ghcr.io/benrhughes/kuma-container-sync:latest .

Run the container (maps Docker socket and sets env):

docker run -d \
  --name kuma-container-sync \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -e KUMA_URL="http://uptime-kuma:3001" \
  -e KUMA_USER="your-user" \
  -e KUMA_PASS="your-pass" \
  -e DOCKER_HOST_NAME="Your Docker Host" \
  -e KUMA_GROUP_NAME="Your Host Group" \
  -e NOTIFICATION_NAME="Your Notification" \
  -e SYNC_INTERVAL=300 \
  ghcr.io/benrhughes/kuma-container-sync:latest

Notes:

  • Ensure DOCKER_HOST_NAME matches an existing Docker Host in Uptime Kuma.
  • If NOTIFICATION_NAME doesnt exist, monitors will be created without notifications.
  • Image includes a Docker HEALTHCHECK that fails if no successful sync has occurred recently (threshold ≈ 2 * SYNC_INTERVAL + 60s).

Architectures: Multi-arch images are published (linux/amd64, linux/arm64). Docker will select the right variant automatically.

Docker Compose Example

Create a docker-compose.yml file:

services:
  kuma-container-sync:
    image: ghcr.io/benrhughes/kuma-container-sync:latest
    container_name: kuma-container-sync
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    environment:
      - KUMA_URL=http://uptime-kuma:3001
      - KUMA_USER=your-user
      - KUMA_PASS=your-pass
      - DOCKER_HOST_NAME=Your Docker Host
      # Optional environment variables
      # - KUMA_GROUP_NAME=Your Host Group
      # - NOTIFICATION_NAME=Your Notification
      # - SYNC_INTERVAL=300
      # - LOGIN_RETRIES=5
    restart: unless-stopped

Run it with:

docker compose up -d

Create a Docker Host in Uptime Kuma

Before running this tool, create a Docker Host entry in your Uptime Kuma instance:

  1. In Uptime Kuma, go to Settings → Docker Hosts.
  2. Click “Add New”.
  3. Set Name to the exact value you will use for DOCKER_HOST_NAME.
  4. Configure the Docker connection (e.g., local socket or remote engine) per your Kuma deployment.
  5. Save. The name must match DOCKER_HOST_NAME so monitors can link to this host.

Local Run (Python)

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
export KUMA_URL="http://uptime-kuma:3001"
export KUMA_USER="your-user"
export KUMA_PASS="your-pass"
export DOCKER_HOST_NAME="Your Docker Host"
python monitor.py

Files

Compatibility

  • This tool targets Uptime Kuma 2.x. Monitor group creation currently uses a low-level client call because a public helper may not be available in all uptime-kuma-api versions used in the wild. Dependencies are constrained in requirements.txt to reduce breakage.

License

Released under the AGPL-3.0 license. See LICENSE.