Giter VIP home page Giter VIP logo

docker-telegram-notifier's Introduction

Docker Telegram Notifier

Create & Publish Docker image

This container contains a Telegram integration to notify about Docker events.

This service notifies about container start, stop, restart events, and changes of Docker healthcheck status. If you wish you can add more event notifications in templates.js file.

This branch was created to patch some security vulnerabilities as well as adding builds for linux/arm64 and linux/arm/v7.

If you spot any problems, feel free to fix it and open a pull request or open a new issue.

๐Ÿณ Run Docker Container

  1. Set up a telegram bot and get the Bot Token. then add the bot to a group and make it admin and extract the Chat ID.

  2. Run a container:

# docker run
docker run -d --env TELEGRAM_NOTIFIER_BOT_TOKEN=token --env TELEGRAM_NOTIFIER_CHAT_ID=chat_id --volume /var/run/docker.sock:/var/run/docker.sock:ro ghcr.io/ivorsmorenburg/docker-telegram-notifier
# docker compose
version: "2.2"

services:
  notifier:
    image: ghcr.io/ivorsmorenburg/docker-telegram-notifier:main
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro # for local instance
      # - ./certs:/certs # for remote instance
    environment:
      # How to create bot: https://core.telegram.org/bots#3-how-do-i-create-a-bot
      # How to get chat id: https://stackoverflow.com/questions/32423837/telegram-bot-how-to-get-a-group-chat-id/32572159#32572159
      TELEGRAM_NOTIFIER_BOT_TOKEN:
      TELEGRAM_NOTIFIER_CHAT_ID:
      # optional args
      # TELEGRAM_NOTIFIER_TOPIC_ID: # Can be provided to specify a topic withing the group
      # ONLY_WHITELIST: true

#  example:
#    image: hello-world
#    labels:
#       telegram-notifier.monitor: true  # always monitor
#       telegram-notifier.monitor: false # never monitor
#       # no label = monitor only when not using whitelist
#    # example docker healthcheck
#    healthcheck:
#      test: curl -sS http://127.0.0.1:8545 || exit 1
#      interval: 30s
#      timeout: 10s
#      retries: 3

Telegram Rate Limit

Respects Telegram Rate Limit using BottleNeck, you can provide some optional enviorment variables

  BN_RESERVOIR | 2 ;
  BN_RESERVOIR_INCREASE_INTERVAL | 2000;
  BN_RESERVOIR_REFRESH_INTERVAL |  60 * 1000;
  BN_RESERVOIR_INCREASE_AMOUNT | 2;
  BN_RESERVOIR_MAX_BUFFER_SIZE | 50 ;
  BN_MIN_TIME | 5000  ;
  BN_MAX_CONCURRENT | 1;
  BN_ID

Debug

Show more logs and traces

  DEBUG | false;

Blacklist and Whitelist

You can suppress notifications from certain containers by adding a label --label telegram-notifier.monitor=false to them.

If you want to receive notifications only from whitelisted containers, set --env ONLY_WHITELIST=true environment variable on the notifier instance, and --label telegram-notifier.monitor=true label on the containers you want to monitor.

Remote docker instance

By default notifier connects to a local docker instance (don't forget to specify --volume /var/run/docker.sock:/var/run/docker.sock:ro for this case). But if you have monitoring and the service on the same host, you will not receive notifications if the host goes down. So I recommend to have monitoring separately.

Credits

This container is based off the container by poma, originally an idea of arefaslani.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.