sabberworm / docker-events-pushover

Receive Pushover notifications on Docker events

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Docker Events Pushover

Receive Pushover notifications on docker container events.

How it works

This script connects to a Docker server, and listens to events using the Docker events API. When certain container events are triggered it sends the affected information to Pushover.

Environment variables

  • PUSHOVER_TOKEN: The app token for your Pushover app. Required.
  • PUSHOVER_KEY: The Pushover API key for your account/group. Required.
  • EVENTS: Whitespace-separated list of events to include. Defaults to create update destroy die kill pause unpause start stop.
  • IGNORE_NAMES: Whitespace-separated list of container names to ignore. Defaults to none.
  • IGNORE_LABELS: Whitespace-separated list of container labels to ignore. Defaults to docker-events.ignore. Label values are not considered.
  • IGNORE_CLEAN_EXIT: Set to a non-empty value to ignore die events that were clean (exit code 0).
  • DOCKER_URL: The connection string for the docker client. Defaults to unix://var/run/docker.sock (socket connection).

Prerequsites

  1. Get a Pushover account
  2. Make a note of your user key (export PUSHOVER_KEY="«INSERT-KEY-HERE»")
  3. Create a new application within pushover, and make a note of the token (export PUSHOVER_TOKEN="«INSERT-TOKEN-HERE»")

Run

  1. Install requirements using pip install -r requirements.txt
  2. Run using python -m docker-events-pushover

Run with docker

When running with the docker instance whose events you try to capture, mount the docker socket using a read-only volume mapping.

docker build . -t «name-of-built-image»

docker run \
    -d --restart=always \
    -v /var/run/docker.sock:/var/run/docker.sock:ro \
    -e PUSHOVER_TOKEN="«INSERT-TOKEN-HERE»" \
    -e PUSHOVER_KEY="«INSERT-KEY-HERE»" \
    «name-of-built-image»

Run with docker-compose

services:
  docker-events:
    build: «/path/to/this/repository»
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    environment:
      - PUSHOVER_TOKEN=«INSERT-TOKEN-HERE»
      - PUSHOVER_KEY=«INSERT-KEY-HERE»
      # Any other env vars you want to configure

License

Apache License Version 2.0

ezoic increase your site revenue

About

Receive Pushover notifications on Docker events

License:Apache License 2.0


Languages

Language:Python 90.8%Language:Dockerfile 9.2%