This issue is likely occurring because you're using localhost:2181 for your Zookeeper hosts. When containers are trying to communicate within a Docker cluster, you should use the service name instead of localhost. This allows the containers to resolve the correct network address within the cluster. enter image description here