Zend certified PHP/Magento developer

Docker SDK: Can’t get accurate number of containers on Worker node from Leader node

I have a swarm with three Managers and one Worker. I also have a monitor_service that tries to use the Docker SDK for Python to get the actual number of containers in a tracked_service. This tracked_service lives on the Worker node.

If I was dealing with a service not on a swarm, I would get the accurate number of containers in that service with the following docker SDK method:

dockerClient = docker.from_env()
containers = dockerClient.containers.list(filters={"name": tracked_service_stack_prefix})
containerCount = len(containers)

On a swarm, however, the above code results in a containerCount of 0. I assume this is because the Docker SDK can only perform container methods on the Leader node, and ignores all other nodes in a swarm. Because my target_service is on the Worker node, I cannot find out its container count.

Is this any way I can get the number of containers in a service that lies on a non-Leader node?

Side-note: I am not talking about the service replica or task counts. I found that these numbers are only the desired number of containers– not the ACTUAL count. Thank you!