Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

A Python client for docker events API.

Project Description


  • have a CLI to start a process which runs abitrary code on docker events
  • be able to provide a way to change behavior of and provide data to event subscribers
  • load subscribers by module or file
  • events may be extended


# pip install docker-events


 # docker-events --help
 Usage: docker-events [OPTIONS]

   -s, --sock TEXT        the docker socket
   -c, --config FILENAME  a config yaml
   -m, --module TEXT      a python module to load
   -f, --file PATH        a python file to load
   -l, --log PATH         logging config
   --debug                enable debug log level
   --help                 Show this message and exit.

 # create a config for skydns
 # cat > skydns-config.yaml << EOF

   domain: foo

     domain: myredis.{domain}

# run skydns subscriber on start events
# docker-events -c skydns-config.yaml -m


There are some predefined events: start, stop, create, die, destroy, pull

You may write your own events like this:

def pull(client, event_data):
    return event_data.get('status') == 'pull'

Events may be extended by other events:

def pull_something(client, event_data):
    return event_data['id'].startswith("foobar")

For example if you want to use skydns, you may want to put the following code into a file or module and load it via -m or -f option:

setup skydns records for containers

import docker_events
import etcd
import simplejson as json

etcd_client = etcd.Client()

def set_skydns_record(client, docker_event, config):
    # get ip of container
    container = client.inspect_container(docker_event['id'])

    container_name = container['Name'].strip("/")
    container_ip = container['NetworkSettings']['IPAddress']

    skydns_config = config.get('skydns', {})
    skydns_containers = config.get('skydns.containers', {
        'domain': 'docker.local'

    # find domain name for this container
    if skydns_config and container_name in skydns_containers:
        # use template
        domain = skydns_containers[container_name].get('domain').format(**skydns_config)

        # join container_name with domain
        domain = '.'.join((container_name, skydns_config.get('domain')))

    domain_path = '/'.join(reversed(domain.split('.')))

    etcd_client.write('/skydns/local/skydns/{}'.format(domain_path), json.dumps({
        'host': container_ip
Release History

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
docker_events-0.0.10-py2.py3-none-any.whl (8.5 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Jul 2, 2015
docker-events-0.0.10.tar.gz (5.3 kB) Copy SHA256 Checksum SHA256 Source Jul 2, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting