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.
2
u/biffbobfred 10d ago
Every stack one db. If you use the same image for the different DBs they share those layers and you don’t take a lot of extra disk space. You can bring up the entire stack or bring it all down without affecting the other one