Docker Integration
Send notifications from Docker containers.
Simple One-Off Notification
Terminal
docker run --rm curlimages/curl \
-X POST 'YOUR_WEBHOOK_URL' \
-H 'Content-Type: application/json' \
-d '{"title": "Container Started"}'Preview
Container Started
just nowIn Docker Compose
services:
app:
image: your-app
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/health"]
interval: 30s
timeout: 10s
retries: 3
notify:
image: curlimages/curl
depends_on:
- app
command: >
-X POST 'YOUR_WEBHOOK_URL'
-H 'Content-Type: application/json'
-d '{"title": "Stack Started", "body": "All services are running"}'Preview
Stack Started
just nowAll services are running
Using Environment Variables
services:
app:
image: your-app
environment:
- PING_WEBHOOK_URL=${PING_WEBHOOK_URL}Then in your application, read process.env.PING_WEBHOOK_URL or equivalent.
Health Check Notifications
Create a sidecar container for health monitoring:
services:
app:
image: your-app
health-monitor:
image: curlimages/curl
depends_on:
- app
entrypoint: /bin/sh
command: >
-c 'while true; do
if ! curl -sf http://app:3000/health > /dev/null; then
curl -X POST "$PING_URL" -H "Content-Type: application/json" -d "{\"title\": \"Health Check Failed\", \"priority\": \"high\"}"
fi
sleep 30
done'
environment:
- PING_URL=${PING_WEBHOOK_URL}Container Exit Notifications
Use a wrapper script in your Dockerfile:
FROM node:20-alpine
COPY notify-wrapper.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/notify-wrapper.sh
CMD ["notify-wrapper.sh", "node", "app.js"]notify-wrapper.sh:
Terminal
#!/bin/sh
"$@"
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
curl -s -X POST "$PING_WEBHOOK_URL" \
-H 'Content-Type: application/json' \
-d "{\"title\": \"Container Exited\", \"body\": \"Exit code: $EXIT_CODE\", \"priority\": \"high\"}"
fi
exit $EXIT_CODE