Docker Community Forums

Share and learn in the Docker community.

Is it a good practice to deploy one docker container for each customer with Docker Swarm?


(Qiulang2000) #1

Whenever I get a new customer I need to deploy a standalone system (a nodejs server, database etc.) for him. I want to streamline the whole deploy process and that is why I am thinking about using Docker, (swarm in particular).

But is it a good practice to deploy one docker container for one customer (only) in Docker Swarm? That container will run the nodejs service while there will be just one DB service in my swarm, but separate db file for each customer.

I have this question because due to my limited understanding of docker, scaling up the replicas seems mainly for load balance when the service nodes can’t handle the traffic. But my usage is one customer one container/service.

Besides, each customer will have its own domain name under my main domain field, e.g. say my company have the domain name ‘xyz dot com’ , then customer A will have the domain name a dot xyz dot com, customer B will have the domain name b dot xyz dot com. How does my nginx service route each customer’s HTTP request to its own container?



(Sam) #2

swarm isn’t really the right way… swarm assumes all the instances are identical, aka horizontal scaling.

it would be ok to use a docker container per customer, with a single DB engine in the back with different databases
or tables per customer… depends on how your solution needs to provide customer data isolation. and protection.

(Qiulang2000) #3

Thanks. I had thought swarm was not the right way and I should use one docker container per customer.
But then I have another problem: to which VM I should run the newly-introduced customer’s container?

I believe I should have some load-balance algorithm to not to start the new container on my most busy server. So is there any load-balance algorithm for that (that was also the reason I had thought use swarm in the first place) ?


(Sam) #4

that shouldn’t be too hard… this is a point in time decision…

run thru hosts, get their current usage (cpu, … whatever u want to use for measure) and
then pick the lowest… you might want to check for having just selected this host on the last startup,
and round robin select one… the problem will be that 10 seconds from now that host might be the least used…

how often will you do this? I wouldn’t think very often.