How to connect WordPress and MySql running on independant containers
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 Solutions collect form web for “How to connect WordPress and MySql running on independant containers”
I can not answer you question but there is a part in the documentation about this:
You will find a section called: Communication between containers
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:
Here are the steps for setup
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.
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.