I am trying to hook on to docker event bus to listen to various events happening on the swarm such as nodes leaving and joining the cluster, services that are created etc. Questions.
Is it possible to get such info at swarm level ?.
If so, Does dockerpy
library be used to listen to such events?
From the docker API documentation: https://docs.docker.com/engine/api/v1.39
Various objects within Docker report events when something happens to them.
Containers report these events: attach, commit, copy, create, destroy, detach, die, exec_create, exec_detach, exec_start, exec_die, export, health_status, kill, oom, pause, rename, resize, restart, start, stop, top, unpause, and update
Services report these events: create, update, and remove
Nodes report these events: create, update, and remove
And from dockerpy documentation: https://docker-py.readthedocs.io/en/stable/api.html?highlight=event
events(since=None, until=None, filters=None, decode=None) Get real-time events from the server. Similar to the docker events command.
Parameters: since (UTC datetime or int) – Get events from this point until (UTC datetime or int) – Get events until this point filters (dict) – Filter the events by event time, container or image decode (bool) – If set to true, stream will be decoded into dicts on the fly. False by default. Returns: A docker.types.daemon.CancellableStream generator
Raises: docker.errors.APIError – If the server returns an error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With