Using service discovery with multiple hosts

I have a stack where one web app needs to call the other, so I thought that service alias would be the best way to handle that (didn’t really want to link the containers together if we could avoid it). The issue I’m running into is that only one of the hosts can resolve the service alias dns, yet I deploy the web apps on both servers (1 on each). Did I go about this the wrong way? Diagram of what I mean is below.

Is the diagram what’s happening?

Have you checked that cross host communication is working? Exec into one of the network agents and ping the IP (10.42.x.x) of the other network agent. If it resolves, then your cross host networking is working. Otherwise, you’ll need to resolve that.

If you deployed two different stacks, they should be able to communicate with each other directly with the stack names. There is no need for any special configuration needed (no need to link the containers). As Denise suggested, please check the cross host networking first. I couldn’t understand what your topology is like from the picture. What do you mean by Foo Web App 1/Foo Web App 2. Are they two different containers in the stack or scaled instances?

Heya, thanks for the reply.

Foo Web App 1, 2 are the same image but set to global so there is one on each host. I think I ended up figuring this out, when we added the hosts to rancher they were added with their public ec2 ip. I removed them and re-added with private ip and then everything seemed to work cross-host. I assume that your hosts are referenced by their private ip… The docs and instructions are a bit misleading as they use Public Ip as the terminology.