A container dies at 2am. Docker restarts it, it dies again, and you find out at 9am from a user who says "the site is broken."
Docker itself never tells you anything. restart: unless-stopped keeps things limping along, but nobody gets a message. Here are five free ways to fix that, from "10 minutes, zero dependencies" to "a proper monitoring stack," with what each one is good and bad at.
Disclosure: option 5 is a tool I'm building. I've tried to be fair to all of them, and the comparison table at the end includes where mine falls short.
1. A small script that watches docker events
Docker already announces every crash on its event stream. You can see it yourself:
docker events --filter type=container --filter event=die --filter event=oom Run a container that exits with an error in another terminal and you'll see a die event with its exitCode. So the simplest alert is a script that reads that stream and posts to a chat webhook:
#!/usr/bin/env bash # crash-alert.sh: send a Discord message when a container dies with an error or runs out of memory. # Needs: docker, jq, curl. For Slack, change {content:$m} to {text:$m}. WEBHOOK="https://discord.com/api/webhooks/XXX/YYY" docker events --filter type=container --filter event=die --filter event=oom --format '{{json .}}' | while read -r e; do name=$(jq -r '.Actor.Attributes.name' <<<"$e") action=$(jq -r '.Action' <<<"$e") code=$(jq -r '.Actor.Attributes.exitCode // empty' <<<"$e") [ "$action" = "die" ] && [ "$code" = "0" ] && continue # clean exit, not a problem msg="Container $name on $(hostname): $action${code:+ (exit code $code)}" curl -s -H 'Content-Type: application/json' \ -d "$(jq -n --arg m "$msg" '{content:$m}')" "$WEBHOOK" >/dev/null done Run it as a systemd service so it survives reboots:
# /etc/systemd/system/crash-alert.service [Unit] Description=Docker crash alerts After=docker.service Requires=docker.service [Service] ExecStart=/usr/local/bin/crash-alert.sh Restart=always [Install] WantedBy=multi-user.target sudo systemctl enable --now crash-alert Two gotchas I hit:
-
docker stopanddocker restartalso producedieevents. If your app ignores SIGTERM, Docker kills it after 10 seconds and the exit code is 137, exactly like a real crash. Docker sends akillevent first when someone stopped the container, so you can subscribe tokilltoo and skip adiethat comes right after one. - Crash loops spam you. With a restart policy, a broken container can die every few seconds. Add a cooldown (for example, remember the last alert time per container in a file and skip anything within 10 minutes).
Good: free, tiny, no new services, you understand every line.
Not so good: only crashes, not errors in the logs. A container that's up but throwing 500s on every request looks perfectly healthy to this script.
2. Uptime Kuma's "Docker Container" monitor
Uptime Kuma is a popular self-hosted uptime monitor, and it can watch containers directly through the Docker socket:
docker run -d --restart=always -p 3001:3001 \ -v uptime-kuma:/app/data \ -v /var/run/docker.sock:/var/run/docker.sock:ro \ --name uptime-kuma louislam/uptime-kuma:1 In the UI, add a Docker host (socket /var/run/docker.sock), then a monitor of type Docker Container for each container you care about. Pick any of its many notification channels (Slack, Discord, Telegram, email, and dozens more).
Add an HTTP monitor for your public URL too. "Container is running" and "site actually works" are different questions.
Good: nice UI, status pages, huge list of notification channels, you probably want it for uptime anyway.
Not so good: checks whether a container is running, on an interval. Short crash-restart cycles can slip between checks, and it doesn't look at logs, so it can't tell you why something failed.
3. Prometheus + cAdvisor + Alertmanager
The classic open-source stack. cAdvisor exposes per-container metrics, Prometheus scrapes them, and Alertmanager sends the notifications.
A common rule for "this container disappeared":
groups: - name: containers rules: - alert: ContainerDown expr: time() - container_last_seen{name="api"} > 60 for: 1m annotations: summary: "Container {{ $labels.name }} hasn't been seen for over a minute" You can also alert on memory close to the limit (before the OOM kill), restart counts and CPU.
Good: extremely powerful, the industry standard, great for metrics and trends, and Grafana dashboards on top look great.
Not so good: four moving parts to run, configure and keep updated on a small server. It's mostly about metrics, not about the error text that tells you what went wrong.
4. Loki + Grafana alerts on error lines
If you want alerts on what your app logs, not just on whether it's running, ship container logs to Grafana Loki (with the Loki Docker logging driver or Grafana Alloy) and create a Grafana alert rule on a LogQL query, for example:
sum by (container) (count_over_time({container="api"} |= "ERROR" [5m])) > 0 Good: catches errors in running containers (the case options 1 and 2 miss), you can search all your logs in one place, and it fits nicely with option 3.
Not so good: more setup and storage to manage, and the alert is "there were errors" plus a count. Someone still has to open the logs, find the right stack trace and work out what changed.
5. Hush (hosted, free during beta)
This is the one I'm building, because options 1–4 still left me reading logs at 2am. Hush is a small agent you install with one command, plus a hosted dashboard:
curl -fsSL https://hushlogs.com/install | sh -s -- --key YOUR_KEY - The agent (Go, about 20 MB of memory) reads container logs and Docker events, keeps only errors and crashes, and groups repeats, so a thousand identical errors become one alert with a count.
- Secrets are removed on your server before anything is sent, and there's a mode that sends no log text at all.
- It tracks deploys, restarts, crashes and OOM kills, so an alert can say "likely trigger: deployed api (v2.2 → v2.3), 2 minutes before the first error".
- An LLM writes a short cause and fix from the redacted lines. You can use your own OpenAI-compatible model (including Ollama) or switch AI off.
- Alerts go to Slack, Teams, Discord, Telegram, email or a webhook.
Good: catches crashes and errors in running containers, no code changes, explains what happened instead of just "something failed."
Not so good: it's a hosted service, not self-hosted, so if your logs can't leave your servers at all, options 1–4 are the right choice. The agent needs the Docker socket, like Uptime Kuma and cAdvisor do. And it's new: free while in beta, with paid plans for more than one server later.
Which one should you pick?
| Setup time | Crashes | Errors in logs | Explains the cause | Self-hosted | |
|---|---|---|---|---|---|
1. docker events script | 15 min | Yes | No | No | Yes |
| 2. Uptime Kuma | 15 min | Yes (on an interval) | No | No | Yes |
| 3. Prometheus stack | Hours | Yes | No | No | Yes |
| 4. Loki + Grafana | Hours | Partly | Yes | No | Yes |
| 5. Hush | 5 min | Yes | Yes | Yes | No |
My honest suggestion:
- One small server, side project: start with option 1 today. It's 15 lines and better than nothing.
- You already want uptime checks and a status page: option 2.
- You have the time and want to learn real observability: options 3 + 4 together are worth it.
- You want to know what broke and why without running a monitoring stack: try option 5.
Whatever you pick, set it up before you need it. The worst time to configure alerts is during the outage.
What do you use to get alerted when your containers break? I'm curious what I missed. Tell me in the comments.

