Docker: a push when a container dies

July 14, 2026 · 4 min read

Containers restart quietly, crash-loop quietly, disappear quietly. A ten-line watcher on the Docker events stream makes every death ring your phone, with the container name in the notification.

The watcher

#!/bin/bash
docker events --filter event=die --format '{{.Actor.Attributes.name}} ({{.Actor.Attributes.exitCode}})' \
| while read line; do
  curl -s -X POST "$WEBHOOKY_URL" -H "Content-Type: application/json" \
    -d "{\"title\":\"🐳 Container died\",\"message\":\"$line\",\"sound\":\"error_1\"}" > /dev/null
done

Run it as a systemd service (or as a tiny container with the Docker socket mounted) and every non-zero exit rings your phone. Filter further with --filter container=… if only some containers matter, or check the exit code in the loop to ignore clean stops.

As a systemd unit

[Unit]
Description=Docker death notifier
After=docker.service

[Service]
Environment=WEBHOOKY_URL=https://api.webhooky.app/YOUR_KEY
ExecStart=/usr/local/bin/docker-notify.sh
Restart=always

[Install]
WantedBy=multi-user.target

Watchtower updates via shoutrrr

If Watchtower keeps your images fresh, it can report through shoutrrr's generic webhook provider:

WATCHTOWER_NOTIFICATION_URL=generic+https://api.webhooky.app/YOUR_KEY?template=json&titlekey=title&messagekey=message

Now image updates land as tidy pushes too, use a friendly sound for those and keep the alarm for deaths.

Compose healthchecks

Pair this with proper healthcheck: blocks in your compose files: an unhealthy container gets restarted by Docker, the restart shows up as a die event, and you learn about flapping services before your users do.

Get Webhooky

100 free notifications every month, set up your endpoint in two minutes.

Get it on Google Play Download on the App Store