Docker Community Forums

Share and learn in the Docker community.

How to define and configure a container for master-master mysql replication

Good Morning. First of all, I apologize if my English is not very good.
I’m not sure in which category I should pigeonhole this question, I would think this is the most appropriate.

I am new to Docker, where I work we are getting familiar with its use. We have a doubt about how we should proceed to a correct use of Docker in a scenario where there will be replication of the mysql database. To be specific: master-master replication.

I set the scenario:
We have a web system installed on a server A (Ubuntu), which we intend to put in Docker.
Our client in his office has a server B (Windows, and with dynamic IP), in which the web system will also be installed. We need to do master-master mysql replication between A and B, and we are not sure how we should proceed with a correct configuration.
We have read and consulted several blogs, and it is not very clear to us. We have found a few proposals, and different ways of defining the container and the docker-compose.yml, etc. But nothing that gives us a clue when different Operating Systems intervene, a dynamic IP scheme, and at one end there will be Docker in the middle. (what we have seen, and as far as we understand, the examples deal with a replication in the same container)

We have done before, these types of master-master replications, and without problems (relying on Hamachi to solve the problem of dynamic IP in the premises of our clients) But in a context where Docker intervenes, not.
How should one proceed with the issue of ports, so that from “outside” (B) it can communicate with mysql of the container in A, and vice versa (from B to A)?
We would be very grateful if you can provide us with a guide and recommendations.

If I was not understood, and / or you need me to provide more information, do not hesitate to tell me.

EDIT:
I was forgetting to comment that what is to be expected is that in A we have many containers, as well as potential clients arise. In each one we intend to have the ecosystem: apache-php-mysql-phpmtadmin and put the systems for each one. Our client actually owns several branches, for now we intend to do it in one. So the scenario would be B1, B2 … Bn. And surely more than one replication will be established, and we should do a correct port address, but we are not sure how.
So, we would be in a case something like this:
A: container-1 <—> B1,
A: container-2 <—> B2,

A: container-n <—> Bn

Best regards,