How to Automatically Detect if Docker (or a Container) is Down?

Hello Team,

We are using docker deployment of open source BI Helical Insight 6.1. Is there any automated way to detect if a Docker container (or service running inside it) goes down and get notified?

Thanks,
Vema.

Hello,

Yes, there are multiple ways to monitor Docker containers and get alerts when they go down. Below are some commonly used approaches based on complexity and use case.

Option 1: Simple Health Check + Alert (Quick Setup)

What to monitor

  • Application endpoint (e.g., API health URL)
  • Or simply check if a port is reachable

How to implement

Use a cron job or script to periodically check:

curl -sf http://localhost:8080/v1/info || echo “Service is DOWN” | mail -s “Alert” you@company.com

Notifications

  • Email
  • Slack webhook
  • MS Teams webhook

Option 2: Use systemd (If Running as a Service)

If your service inside Docker is managed via systemd:

1. Check service

systemctl status your-service

2. Enable auto-restart

Restart=on-failure
RestartSec=10

3. Add failure alert

OnFailure=alert-service@%n.service

Automatic restart + alert
Triggers only on real failure

Option 3: Proper Monitoring (Best Practice for Production)

Tools

  • Prometheus + Alertmanager
  • Grafana
  • Datadog / New Relic
  • Zabbix / Nagios

What to monitor

  • Container up/down status
  • CPU / Memory usage
  • Application health endpoints
  • Errors and logs

Example metrics endpoint

http://:8080/metrics

Option 4: Docker Native Healthcheck (Recommended for Containers)

If you’re using Docker, this is the cleanest approach. Helical Insight use this method.

Add healthcheck in Docker

healthcheck:
test: [“CMD”, “curl”, “-f”, “http://localhost:8080/v1/info”]
interval: 30s
timeout: 5s
retries: 3

What happens

  • Docker marks container as:
    • healthy
    • unhealthy
  • You can then:
    • Monitor via docker ps
    • Integrate with monitoring tools for alerts

Native Docker solution
Works seamlessly with orchestration tools
No need of external alerting for notifications

Summary

  • Multiple approaches available depending on setup
  • Docker healthcheck is the most straightforward for containers
  • Combine with alerting tools for complete monitoring

Thank You,
Helical Insight.