0

Wordpress is running inside a Docker container on hostA and MySQL is running inside a Docker container on hostB. Is it possible to link these two containers to communicate to each other? Is this even possible to do something like this?

Any help on this is much appreciated as am pretty new to Docker

3 Answers3

0

I can not answer you question but there is a part in the documentation about this: https://docs.docker.com/engine/userguide/networking/default_network/container-communication/

You will find a section called: Communication between containers

0

Yes this is possible with docker overlay network.

The setup is not as easy as setting up a link or private network on the same host. You will have to configure a key value store to get this working.

Here is the relevant docker documentation.

An overlay network:

https://docs.docker.com/engine/userguide/networking/dockernetworks/#an-overlay-network

Here are the steps for setup

https://docs.docker.com/engine/userguide/networking/get-started-overlay/

In my opinion, its not bad to isolate the app and database containers and connect outside the docker network. If you end up adding the key/value store like consul, you can always leverage the service discovery that comes along with it to dynamically discover the services.

Shibashis
  • 8,023
  • 3
  • 27
  • 38
0

I would go for https://github.com/weaveworks/weave.

Weave Net creates a virtual network that connects Docker containers across multiple hosts and enables their automatic discovery.

It might be overkill for your usecase. But it would be very helpful if you want to move the containers around in the future.

Wei Qiu
  • 886
  • 9
  • 16