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

  • req-flash session issues using express within docker container
  • Running a Self-Developed Python Server on Docker Container
  • Log management on Docker
  • Docker nginx and Go (Golang) separate containers. Nginx configuration
  • Use data of docker container inside another
  • Sporadic 503s from specified ports
  • GCS Fuse on docker container error
  • Docker run appears to ignore the name argument
  • How to disable icc including published ports in Docker
  • Is it a bad idea to use docker to run a front end build process during development?
  • Having error pushing docker container on Bluemix
  • Get log of a systemd/journald in a docker container to “docker logs”
  • 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:
    https://docs.docker.com/engine/userguide/networking/default_network/container-communication/

    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:

    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.

    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.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.