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?
With Docker compose, you can configure and start multiple containers with a single yaml file. This is really helpful if you are working on a technology stack with multiple technologies.
Surprisingly or not, neither Docker nor Podman support exposing multiple containers on the same host's port right out of the box. Example: docker-compose failing scenario with "Service specifies a port on the host. If multiple containers for this service are created on a single host, the port will clash."
You can not deploy multiple containers per VM. Please consider this limitation when deploying containers on VMs: 1. You can only deploy one container for each VM instance.
Docker is especially suited to the deployment of microservices. The following links discuss two strategies with regard to the use of databases:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With