<p>Docker and all the other fancy names are just tools. The examples are just examples. </p>

<p>Resource-wise, Docker changes nothing much beyond usual Linx/Unix multiprocessing. It does not have the overhead of VMs, and little overhead over just starting the process directly ( <a href="https://stackoverflow.com/questions/21889053/what-is-the-runtime-performance-cost-of-a-docker-container">https://stackoverflow.com/questions/21889053/what-is-the-runtime-performance-cost-of-a-docker-container</a> ).</p>

<p>So it is really up to you to decide how to use it. If you have closely related applications under your own command, maybe in your intranet, why not use a shared DB. If they are customer DBs, or you might need to run different versions of the software, or different incompatible configurations, then separate services might be fine.</p>

<p>For RDBMSses especially, they are usually very good at managing resources (RAM, HDD) and so for this case specifically, running only one may just be the best thing. It's really more about what your needs are than general guidelines.</p>

CC BY-SA 3.0
2017-09-28T09:07:06.917Z
Yes I realized they were just examples, but unfortunately there were no examples of running multiple sites. I will make some list of requirements and decide based on that. Good to know that I should not rule out multiple DB containers to begin with.
Neograph734
CC BY-SA 3.0
2017-09-28T17:58:17.987Z
Yeah. One case where it is great to dockerize, say, PostgreSQL is for development and throwaway CI/CD environments. OTOH, I would not dockerize a heavy-lifting Oracle DB, probably...
AnoE
CC BY-SA 4.0
2020-08-19T11:11:15.823Z
What about MySQL, would you dockerize it and run an instance for each application or would you choose a shared MySQL server with multiple databases in it?
Sam
CC BY-SA 4.0
2020-08-20T15:56:19.737Z
@Sam, following the spirit of my answer, it would depend wholly on the use case. There are official MySQL docker images easily available; I would most definitely use them unless I had good reason against that (the latter being for example if I were a DBA running a *huge* dedicated DB installation used by many clients). OTIH, spinning up a quick MySQL service in a Kubernetes cluster? Sure... (be sure you know how to handle the persistent volumes...).
AnoE
CC BY-SA 4.0
2020-08-24T09:14:51.390Z
I was talking about a single MySQL container vs multiple MySQL containers. Is MySQL lightweight enough to run multiple MySQL containers? Each for its own application.
Sam
CC BY-SA 4.0
2020-08-24T09:27:16.260Z
Sure, I think it's regularly used in that way (small containers), @Sam.
AnoE
CC BY-SA 3.0
2017-09-27T05:39:09.410Z
2017-09-27T05:39:09.410Z
AnoE
<p>So I have been reading up on Docker, and I cannot quite get my head around this concept. There are literally dozens of tutorials on the web about spawning a Wordpress instance on Docker within 5 minutes. All these sites spawn their processes separately; a singe SQL container, a single webserver container and a PHP + filesystem container. </p>

<p>Apparently the Docker philosophy is to keep everything nice and small and separated. Proper isolation, distribution and scalability; all fine. But what if I need two Wordpress sites, or ten? </p>

<p>The advantage of separate containers is that every site can be instantiated with its own passwords and other secrets via a docker-compose file, but having 10 database containers running next to each other feels like wasting resources. Once single SQL container should be capable of running 10 databases.</p>

<p>I was wondering if running multiple instances is indeed resource heavier, and/or if the added value of strict isolation outweighs the resource usage?</p>

<p>(I have chosen SQL, but the question basically applies to all resources that can be shared across sites. Think of mailservers, virus scanners, etc.)</p>

<docker><containers><scalability>
Running multiple websites on Docker in isolated or shared database containers?
Neograph734
# Running multiple websites on Docker in isolated or shared database containers?

(Asked by: username_0 on 2017-09-26)

So I have been reading up on Docker, and I cannot quite get my head around this concept. There are literally dozens of tutorials on the web about spawning a Wordpress instance on Docker within 5 minutes. All these sites spawn their processes separately; a singe SQL container, a single webserver container and a PHP + filesystem container.

Apparently the Docker philosophy is to keep everything nice and small and separated. Proper isolation, distribution and scalability; all fine. But what if I need two Wordpress sites, or ten?

The advantage of separate containers is that every site can be instantiated with its own passwords and other secrets via a docker-compose file, but having 10 database containers running next to each other feels like wasting resources. Once single SQL container should be capable of running 10 databases.

I was wondering if running multiple instances is indeed resource heavier, and/or if the added value of strict isolation outweighs the resource usage?

(I have chosen SQL, but the question basically applies to all resources that can be shared across sites. Think of mailservers, virus scanners, etc.)

**Tags:** docker, containers, scalability


---

## 1 answers

### Answer by username_1 on 2017-09-27. Score: 3 | Accepted answer

Docker and all the other fancy names are just tools. The examples are just examples.

Resource-wise, Docker changes nothing much beyond usual Linx/Unix multiprocessing. It does not have the overhead of VMs, and little overhead over just starting the process directly ( <https://stackoverflow.com/questions/21889053/what-is-the-runtime-performance-cost-of-a-docker-container> ).

So it is really up to you to decide how to use it. If you have closely related applications under your own command, maybe in your intranet, why not use a shared DB. If they are customer DBs, or you might need to run different versions of the software, or different incompatible configurations, then separate services might be fine.

For RDBMSses especially, they are usually very good at managing resources (RAM, HDD) and so for this case specifically, running only one may just be the best thing. It's really more about what your needs are than general guidelines.

> **Comments:**
> **username_0**: Yes I realized they were just examples, but unfortunately there were no examples of running multiple sites. I will make some list of requirements and decide based on that. Good to know that I should not rule out multiple DB containers to begin with.  
> **username_1**: Yeah. One case where it is great to dockerize, say, PostgreSQL is for development and throwaway CI/CD environments. OTOH, I would not dockerize a heavy-lifting Oracle DB, probably...  
> **username_2**: What about MySQL, would you dockerize it and run an instance for each application or would you choose a shared MySQL server with multiple databases in it?  
> **username_1**: @username_2, following the spirit of my answer, it would depend wholly on the use case. There are official MySQL docker images easily available; I would most definitely use them unless I had good reason against that (the latter being for example if I were a DBA running a *huge* dedicated DB installation used by many clients). OTIH, spinning up a quick MySQL service in a Kubernetes cluster? Sure... (be sure you know how to handle the persistent volumes...).  
> **username_2**: I was talking about a single MySQL container vs multiple MySQL containers. Is MySQL lightweight enough to run multiple MySQL containers? Each for its own application.  
> **username_1**: Sure, I think it's regularly used in that way (small containers), @username_2.  

---

