Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

API to listen to docker swarm events

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.

  1. Is it possible to get such info at swarm level ?.

  2. If so, Does dockerpy library be used to listen to such events?

like image 837
B_B Avatar asked Oct 30 '22 11:10

B_B


1 Answers

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.

like image 99
vimal-k Avatar answered Nov 11 '22 14:11

vimal-k