I haven’t tried this before but there seems another way to connect containers from different host machines: overlay network and swarm.
Initializing a docker swarm needs 3 host machines (manager and workers, the manager can also be a worker) and some ports opened in each host.
I think it is just like trying to set up a VPN but in the docker’s way. This “3” is a bit annoying though.
Anyways, you may want to give it a shot now that we have more topic names available to check 
Hi everyone,
I established successfully the replica set Mongo with a hybrid different shell server outside and container inside. There are 7 members is distribute 3 machines differently and members are running on both container and shell in the same machine.
My way is not need to set up a subnet, swarm mode or any VPN anymore, I just expose port directly from the container to outside, through that they can ping each other without getting any prevention.
Many thanks for your effort support !!
Hi @Khiem_Nguy_n , glad to hear back and know you could solve the problem. but can you please apply the following two steps:
- reply also to your other topic so others will know the problem was solved.
- describe the missing part a bit more clearly. was it a missing port mapping all this time? or firewall or something else?
by the way, 7 is one of those high numbers that may have unseen port problems. have you tested the network? by “stepping down” primary members (rs.stepDown()) and also removing members from majorities by shutting down individually (login to a member, not to replicaset)?