Skip to content

Instantly share code, notes, and snippets.

@jhaubrich
Created June 19, 2014 15:35
Show Gist options
  • Save jhaubrich/22a8b9d02f2b49ee8b35 to your computer and use it in GitHub Desktop.
Save jhaubrich/22a8b9d02f2b49ee8b35 to your computer and use it in GitHub Desktop.
docker event reader - Just prints out docker events. Find the docker host from the environment variable DOCKER_HOST
import os
import json
import requests
def read_stream(stream):
raw_json = ''
for ch in stream.iter_content():
raw_json += ch
if ch == '}':
yield raw_json
raw_json = ''
docker_host = os.environ['DOCKER_HOST'].replace('tcp', 'http')
r = requests.get(docker_host + '/events', stream=True)
for o in read_stream(r):
print o
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment