So I’m in the process of (re-) setting up my homelab and unsure about how to handle databases. Many images require a database, which the docker-compose usually provides inside the stack.
Now my question, shall I have 1 database container which is accessed by all containers? Or shall I have a separate container for each service?
For critical services, which shall have as few dependencies as possible I’m already using sqlite or a similar solution.
Also on a sidenote: I have two docker hosts, can I let the containers of 1 hypervisors use the same internal docker network?
TIA!
Personally, I maintain a separate compose file for each “end-user service.”
So, e.g. Nextcloud has its own compose file, including a Nextcloud-specific redis and database. That way, if I need to migrate my Nextcloud instance to a different server, I don’t have to disentangle its database from e.g. the database that my FreshRSS installation is using.
This also provides some benefits in terms of security. If one of my services turns out to have a SQL injection vulnerability, keeping its data in a separate database means the systemic damage will remain compartmentalized.
The compute overhead for most of these “backing databases” is negligible. I think it’s worth the overhead.