Best practice for sharing databases

This is my first post, so hello to you all!

I’ve been toying with Docker on CentOS 7 and have reached a point where I need your advice on the way to go.

If I take wordpress as an example. If I’d like to host two wordpress sites on a single host, what would you recommend I do?

  1. Create two containers each of which contains all that is needed to run wordpress?
  2. Create three containers. Two wordpress containers that both link to a db container?
  3. Create four containers. A db container for each wordpress container?
  4. A database on the host serving two wordpress container?
  5. You got it all wrong, do it my way!

I get the basic structure of Docker, I’m just unclear about the best way to apply it in a “complex” environment.

Any help or pointers to documentation are welcome :smile:

Cheers.

In many ways, the decision depends on your needs for separation, scaling and upgrade strategies.

typically, it would make sense to have some kind of caching proxy in front of a larger wordpress (or web application application) to reduce the redundant loads, and to later allow for scaling out.

And this proxy, or load balancing container, is then able to pass the requests to the right wordpress container (based I presume on domain name?), which then talks to its own database container.

As you learn about your scaling issues, you’ll then be able to add more servers, migrate your containers, and add more containers to deal with your load profiles.

However - if you’re just at an early stage, its just as valid to start with one proxy to route the requests, 2 wordpress containers and a common database. It really depends.

Hi Sven,
Thanks for your answer!

If I get interpret what you are saying, the db container can be shared by multiple containers but any app should run in its own container for scalability and manageability. I like your mention of a proxy, it will add a layer of complexity and test my newb status.