用于mysql的多个docker容器或具有多个数据库的一个实例

用于mysql的多个docker容器或具有多个数据库的一个实例

问题描述:

我对使用Docker容器的最佳做法有疑问.

I have a question regarding best practices using docker containers.

我为开发的每个应用程序需要一个数据库.现在我的问题是我应该使用一个带有多个数据库的mysql docker实例还是应该为每个数据库创建一个实例.我为每个数据库创建一个实例时看到的缺点是我无法拥有可以访问所有数据库的用户.我出于安全原因知道这是一个专家,但是当我尝试从客户端进行备份时,需要在每个实例中进行备份.并且不是多个实例占用大量资源(虽然mysql可能使用的资源较少,但是使用e.x. mssql实例(退出的更大)可能会在以后导致资源问题)

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)

我的问题是,使用docker的常见方法是什么?利弊是什么?

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

Docker特别适合于微服务的部署.以下链接讨论了有关数据库使用的两种策略:

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

  1. 每个服务的数据库
  2. 共享数据库
  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.