docker-events-notifier

command module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2020 License: MIT Imports: 19 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

docker-events-notifier

Docker events notifier

Slack or Email notifications for docker events on your host, < 10mb image, no exposed ports

https://hub.docker.com/r/hasnat/docker-events-notifier/

docker-events-notifier

Look for config, template for email, slack Example

Docker events Reference

Example usage

Cli

docker run -it \
    --name docker-events-notifier \
    -e HOST_TAG=local \
    -e DOCKER_API_VERSION=1.39 \
    -e RLOG_LOG_LEVEL=DEBUG \
    -v "/var/run/docker.sock:/var/run/docker.sock" \
    -v "$(pwd)/config.yml:/etc/docker-events-notifier/config.yml" \
    -v "$(pwd)/templates:/etc/docker-events-notifier/templates" \
    hasnat/docker-events-notifier

Compose

version: '2'

services:

  docker-events-notifier:
    image: hasnat/docker-events-notifier
    container_name: docker-events-notifier
    environment:
      HOST_TAG: local
      DOCKER_API_VERSION: "1.39"
      RLOG_LOG_LEVEL: DEBUG
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "./config.yml:/etc/docker-events-notifier/config.yml"
      - "./templates:/etc/docker-events-notifier/templates"

Local build

Run & develop locally by, check docker-compose.override.yml

docker-compose up --build

Example config

Design you config by looking into docker events & jq command


notifiers:
  slack:
    url: "https://hooks.slack.com/services/XXXX"
    template: /etc/docker-events-notifier/templates/slack.json
  email:
    url: "smtp://user:pass@some.mail.host:587?from=sender@example.net&to=recipient1@example.net&to=recipient2@example.net"
    template: /etc/docker-events-notifier/templates/email.txt



# global filters ( check https://docs.docker.com/engine/reference/commandline/events/#filter-events-by-criteria )
filters:
  event: ["stop", "die", "destroy"]
#  container: ["some_container_name"]
#  image: ["hasnat/docker-events-notifier"]



notifications:
  - title: "Alert me when tianon/.* based container dies with exitCode 1"
    when_regex:
      status: ["(die|destroy)"]
      "Actor.Attributes.image": ["tianon/.*"]
    when:
      "Actor.Attributes.exitCode": ["1"]
    notify:
      - email
      - slack

  - title: "Alert only on slack when container dies with exitCode 0"
    when_regex:
      status: ["(die|destroy)"]
      "Actor.Attributes.image": ["hasnat/.*"]
    when:
      "Actor.Attributes.exitCode": ["0"]
    notify:
      - slack

  - title: "Alert me on anything happening to images by hasnat"
    when_regex:
      "Actor.Attributes.image": ["hasnat/.*"]
    notify:
      - email
      - slack

TODO:

  • Allow https or local unix socket for docker host
  • Group notifications and schedule sending
  • Split secrets (notifiers) from Config

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址