import docker client = docker.from_env() def container_handler(event): print("Container %s %s" % (event["status"], event["id"])) for event in client.events(filters={"event": ["start", "stop"]}): container_handler(event)In this example, the Docker client is used to create a connection to the Docker daemon. The `container_handler` function is defined to handle container start and stop events by printing their status and ID. The `client.events` method is then used to listen for events filtered by "start" and "stop". Python Docker Client events is part of the larger Docker SDK for Python library.