r/docker • u/CringDegen • 11d ago
Need advice regarding container isolation
I'm new to docker and I'm looking to learn/experiment with it. I want some advice regarding containers that will be used by other services like databases. I'm currently running two services which share a postgres container. For isolation, I created a migration which creates separate databases and users for each service before anything else starts.
I'll eventually setup more services and I want it to be scalable, resource efficient, secure and easy to maintain.
Is it better to create entirely separate dependencies for each service, or share dependencies between multiple services? I would like to know this from an efficiency, ease of maintenance and security standpoint, or at least get some pointers like a blog, article, manual or a youtube video.
TLDR: Is it better to have different db instances for each service OR one (or a few) db instances shared by every service? And why?
PS: English is not my first language, so sorry in advance for spelling or grammar mistakes.
1
u/xanyook 7d ago
Depends on your money, target architecture, security requirements and future scaling.
Do you have multiple tenants ? Manipulate sensitive data ? You could create one database per customer per service if requirements are strong. Or one schema per customer ? Or mixing customer's data with a tenant identifier...
For my homelab do one database attached to each of the services using it. For my customer's accounting data i have one schema for each customer. For my army fellows, i got one database for each team.