37

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?

hesyar
  • 467
  • 1
  • 5
  • 12

1 Answers1

34

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.

Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • thanks for answer. While you develop bunch of services (not in production) do you use this approach too? – Bukharov Sergey Jan 27 '17 at 07:24
  • @BukharovSergey Certainly. In my case it's no hardship to spin up a single DB instance, to which multiple copies of the app container connect to. – Mark O'Connor Jan 27 '17 at 18:43