Multiple docker containers for mysql or one instan

2020-05-23 03:01发布

问题:

I have a question regarding best practices using docker containers.

I need one database for each application I develop. Now my question is whether I should use one mysql docker instance with multiple databases inside or should I create one instance for each database. The disadvantage I see with creating one instance per database is that I can't have a user which has access to all database. I know this is a pro for security reasons but when I try to backup from a client than I need to go in every instance for backup up. And isn't multiple instance using to much overhead of resources (although mysql may be using less resource, but using e.x. mssql instance which is quit bigger may cause resource problems later)

My question is what is the common way to do it with docker and what are the pros and contras?

回答1:

Docker is especially suited to the deployment of microservices. The following links discuss two strategies with regard to the use of databases:

  1. Database per service
  2. Shared database

I personally favour the use of a single database per service and extend that to the deployment of separate instances of a database server. This ensures services are loosely coupled, should one service suffer a DB outage, it won't impact another.