Facilitating the management of the traditional networks, Software Defined Networking (SDN), separates data plane and control plane, so providing advantages such as programmability, flexibility, and cost-effective configuration. But, SDN has some problems such as security, infrastructure, single-point-of-failure, and controller placement. A single-point-of-failure problem can be solved with a multi-controller; however, it needs to be improved. The most critical issue in solving the multi-controller placement problem is minimizing latency between controllers and their associated switches. In this paper, an SDN-based multi-controller system using Docker-swarm mode is presented to solve the single-point-of-failure problem, and using the presented system, the multi-controller placement problem is solved with optimized k-means (Opk-means) in order to reduce the end-to-end latency. The experimental results show that the proposed testbed provides a high availability control plane for multi-controller, and the Opk-means algorithm significantly reduces the latency when compared to the standard k-means in the testbed.