Docker, use mysql in multiple Containers

Hi, I’m new and I have a question.
Let’s say I want to have 2 instances of Wordpress, 1 Odoo, and some other container that uses a mysql database.

How do I make sure there is only one mysql running with multiple databases, one for each container on the server and not have each container install a different version of mysql.

Or is it better for each instance to have its own separate mysql???

Thanks

Sure, you can run multiple services/containers and connect to a single database.

My personal recommendation is to use Docker compose files with explicit Docker network to connect the services.

The only challenge is that DB images usually just come with a single admin user to be configured by variables. So you should manually connect to DB and create individual databases and users for every service.

Sounds good!, how about having the db image in 2 (or more) different docker compose files (one per each project) any suggestions on how to handle this?

What do you mean? You want to run two db containers, one in each compose? Sure, you can do that.

But they should not share the same database storage files. If you want to use the same data and share it, you have to use a single db instance.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.