rycochet/docker-discord-alerts

By rycochet

Updated 8 months ago

Monitor your Docker containers effortlessly and receive real-time alerts in Discord

Image
Monitoring & observability
0

1.1K

rycochet/docker-discord-alerts repository overview

docker-discord-alerts

GitHub Actions Workflow Status GitHub contributors Docker Pulls Docker Image Size

Monitor your Docker containers effortlessly and receive real-time alerts in Discord. This project leverages Docker Compose to run the monitoring script as a continuous service, ensuring you stay informed on container events such as start, stop, restart, and failures.

Features

  • Real-Time Monitoring: Listens for Docker container events.
  • Discord Notifications: Sends event alerts to a Discord channel using webhooks (no bot required).
  • Rich Embeds: Optional detailed information.
  • Configurable: Easily customize alerts using a ENV vars.
  • Dockerized: Run the script as a background service using Docker Compose.

Prerequisites

  • Docker and Docker Compose installed on your system.
  • A Discord account and a webhook URL from your server.

Usage

  1. Create a compose.yaml file

    An example compose.yaml file is included, make sure you replace the DISCORD_WEBHOOK_URL value with one you obtained from Discord:

    services:
        docker-discord-alerts:
            container_name: docker-discord-alerts
            image: ghcr.io/rycochet/docker-discord-alerts:latest
            restart: unless-stopped
            volumes:
                - "/var/run/docker.sock:/var/run/docker.sock:ro" # or use the `DOCKER_HOST` variable
            environment:
                DISCORD_WEBHOOK_URL: "https://discord.com/api/webhooks/..."
    
  2. Start the Service

    Use Docker Compose to start the service in the background:

    docker-compose up -d
    
  3. Trigger Docker Events

    Start, stop, or restart Docker containers to trigger notifications:

    docker start your_container_name
    docker stop your_container_name
    docker restart your_container_name
    
  4. Check Discord

    Notifications will appear in the designated Discord channel with details about each container event.

Troubleshooting
  • Ensure Docker and Docker Compose are running correctly.

  • Verify that the Discord webhook URL is correct and active.

  • Check for any errors in the container logs:

    docker logs docker-discord-alerts
    

Environment Variables

NameDefinitionDefault
DISCORD_WEBHOOK_URLRequired
The full webhook URL from Discord, see here
CONTAINERSA comma-separated list of container names, or * for "everything"*
DOCKER_HOSTIf using socket-proxy you should pass the URI for it here.
EVENTSA comma separated list of events to watch. There are two special values, all for everything, or default for a smaller list (see separate table).default
EXTRAA string to send with every alert, perfect for sending @mentions for people. You need to obtain the ID (see here) and format as <@USER_ID> or <@&ROLE_ID>, but can put any text here.
LOG_LEVELHow much to log: DEBUG, INFO, WARNING, ERROR, CRITICALINFO
VERBOSEProvide more detail for the Discord messages. (True / False)False

Docker Events

These are the supported docker events, and the colour of the notifications for each.

EventDescriptionDefault
create#CCFFCC ⏺️ Container Created
start#00FF00 ▶️ Container Started
pause#FFA500 ⏸️ Container Paused
unpause#A5FF00 ⏯️ Container Unpaused
restart#00FFA5 🔁 Container Restarted (will also show both stop and start)
stop#CC0000 ⏹️ Container Stopped
kill#AA0000 💀 Container Killed
die#FF0000 ⏏️ Container Died (includes both stop and kill)
health_status#712EFF 🩺 Health Status

Tag summary

Content type

Image

Digest

sha256:07dd01802

Size

21.6 MB

Last updated

8 months ago

docker pull rycochet/docker-discord-alerts