Search code examples
dockerswarm

Docker events - when will the swarm node update event be emitted?


I’m trying to detect changes in services inside a swarm: I'm listening for notifications with docker events on a manager node and then I'm going to stop some running container on a worker node.

Sometimes I receive a node update event, sometimes not. I thought it might be related to moving and restarting the container on another node, but that does'nt always trigger an event.

I wasn’t able to find valid rules. So I wonder when exactly such event will be emitted? Or why it might not?

Edit: Furthermore, shouldn't there be a "service update" event as well, when a new container is started? Which swarm events should occur?


Solution

  • AFAICT after further investigation "node update" events arrive when the first container of a given stack is created and/or started or if the last container of a certain stack is stopped/killed.

    This was some kind of "mystery", because sometimes it worked (event occurred), sometimes not. Unfortunately this does not help me to trigger an enumeration on swarm manager, so I need to implement an "agent" on every node.

    "service update" events only seem to occur when the service is changed (set label or property).