Create an event emitter from dockerode's events response
Docker exposes an event API, allowing one to monitor the happenings of a Docker host. dockerode allows for consumption of this API, albeit in a very raw form. docker-events does a bit of work for you, turning the raw API of dockerode into something a little more high-level by parsing the response stream and pushing things out of an EventEmitter.
var emitter = new DockerEvents({
docker: new Dockerode(options),
});emitter.start();emitter.stop();emitter.on("connect", function() {
console.log("connected to docker api");
});emitter.on("disconnect", function() {
console.log("disconnected to docker api; reconnecting");
});Any raw event from Docker.
emitter.on("_message", function(message) {
console.log("got a message from docker: %j", message);
});Events are emitted in a form of <event.Type>:<event.Action>.
Full list of events: https://docs.docker.com/reference/api/engine/version/v1.52/#tag/System/operation/SystemEvents
For example:
emitter.on("container:create", function(message) {
console.log("container created: %j", message);
});
emitter.on("container:start", function(message) {
console.log("container started: %j", message);
});3-clause BSD. A copy is included with the source.
- GitHub (deoxxa)
- Twitter (@deoxxa)
- Email (deoxxa@fknsrs.biz)