I am trying to connect two docker containers from two different hosts.I have configured web container on host A and DB container on host B.I have tried to connect(link) these two containers by using docker swarm and weave but it did not work for me.need some suggestions how to link two containers from two different hosts.
Asked
Active
Viewed 789 times
3
-
you can use services on docker swarm – Constantin Galbenu Apr 17 '18 at 13:48
-
1Where is the [mcve](https://stackoverflow.com/help/mcve)? :-) – tgogos Apr 17 '18 at 13:58
-
Can you be a bit more explicit what you tried? E.g. post the sequence of commands and the output. "link" used to be a feature of Docker but is deprecated a long time ago. – Bryan Apr 17 '18 at 14:02
-
I'm trying to connect Drupal container and MYSQL container from different hosts. – Rakesh Sivagouni Apr 17 '18 at 14:59
1 Answers
1
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.

Bret Fisher
- 8,164
- 2
- 31
- 36