Skip to content

Conversation

@austinc3030
Copy link

Summary

This PR adds a built-in healthcheck command to the cloudflare-ddns binary, enabling Docker health monitoring for DDNS update containers.

Changes

Code Changes

  • Added --healthcheck flag to the main binary in cmd/ddns/ddns.go
  • Implemented healthcheckMain() function that:
    • Validates configuration
    • Detects current public IP address(es)
    • Attempts to update DNS records
    • Returns exit code 0 on success, 1 on failure

Documentation Changes

  • Added comprehensive "Docker Health Monitoring" section to README
  • Included Docker Compose healthcheck example
  • Documented healthcheck configuration options
  • Added best practices for healthcheck timing and IPv6 considerations
  • Provided monitoring commands and usage examples

Dockerfile Changes

  • Added whitespace formatting for better readability

Why This Feature is Useful

Docker healthchecks provide automated monitoring of container health, which is crucial for production deployments:

  1. Automatic Failure Detection: Detect when DDNS updates fail without manual monitoring
  2. Container Orchestration: Enable automatic restarts or failover in Docker Swarm/Kubernetes
  3. Monitoring Integration: Works with standard Docker health status monitoring tools
  4. Real-world Validation: Tests the actual DDNS update process, not just if the binary is running

Usage Example

healthcheck:
  test: ["CMD", "/bin/ddns", "--healthcheck"]
  interval: 5m
  timeout: 30s
  start_period: 30s
  retries: 3

Testing

  • Verified the --healthcheck flag correctly validates configuration
  • Tested successful healthcheck with valid credentials and IP detection
  • Confirmed proper error reporting when configuration or updates fail
  • Validated exit codes (0 for success, 1 for failure)

Important Notes

⚠️ Users should set IP6_PROVIDER=none if their Docker environment doesn't support IPv6, as the healthcheck will fail if either IPv4 or IPv6 detection fails when both are enabled.

@Sc0rc3d
Copy link

Sc0rc3d commented Oct 17, 2025

I would Love healthcheck in this Image!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants