How to connect two docker containers from two different hosts? How to connect two docker containers from two different hosts? docker docker

How to connect two docker containers from two different hosts?


You want to use Swarm Services with the default Overlay networks built into Swarm Mode (SwarmKit).

Those two containers would then be in their own Service and part of the same overlay network where they could easily let them talk to each other between nodes using their service name (which is their DNS name).

Go through the 6-part setup of getting started with Docker and it will teach you compose files, Swarm Services, and more.