Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I reflect the data in one container to another?

I have 3 docker MySQL container running and I am trying to replicate the data in one container to another.

if I create a database in one mysql-container the other mysql-container should get updated with the the changes I made.

I tried and I did not find a way to do that.

How to make this happen ?

like image 884
Vishnu Ranganathan Avatar asked Dec 07 '25 08:12

Vishnu Ranganathan


2 Answers

You need to setup an standard replication between mysql containers.

You cannot use something like volume to share mysql data at file level because the mysql's will mess the things up and corrupt data for sure.

You can make a replication as Master-Slave scheme or Master-Master (according to your needs).

Refer to the docs to have detailed information.

like image 167
Robert Avatar answered Dec 09 '25 23:12

Robert


I think @Robert is absolutely right in that you can probably start with a simple master-slave or master-master schema.

Since you mentioned Docker, I think the AutoPilot Pattern is a good repository to start. They have a solution for MySQL (replication, backups, failover, ...). Here is where you can find it https://github.com/autopilotpattern/mysql

like image 29
Nima Esmaili Mokaram Avatar answered Dec 10 '25 00:12

Nima Esmaili Mokaram