I am running multiple named docker containers (200+) on my VM Host. I have a manager script/code that is supposed to manage the containers from the host. I would like to know if there is any event-based mechanism to get notified when a container stops/fails. So that I can restart the stopped container.
One solution I could think of is doing a periodic docker inspect and looking at State.Pid
or State.Running
to confirm the status.
But,instead of periodic polling, it would be better if the manager is notified with pid/name when a container fails so that, the particular container alone can be restarted.
On a general note, are there ways to programmatically monitor the status of a process from a different process that is not the parent ?