Docker swarm network not working properly in different subnets of AWS

I have created the AWS VPC(virtual private cloud), In that I have two subnets, first is public and second is private. I have installed docker on both the subnets in their respective instances and Created swarm network between them.

When I run command “Docker network ls”, its shows both manager and worker node. but whenever I am trying to connect container from one subnet to another its fails means they are not communicating with each other. I have one phpadmin container in public subnet and mysql container in private subnet. They both are connected through “–link”.

I have opened respected ports for communication: 2377, 7946, 4789, 3306, 80, 443, 22

Please assist me why this containers are not communicating with each other? What I am supposed to do for its communication?

Source: StackOverflow