Keep two Docker Volumes in sync in different nodes on the same cluster
582
GitHub: moveyourdigital/docker-unison-sync
This repository distributes unison in a Dockerfile intended to synchronize two different volumes of a containerized cluster (Kubernetes, Docker Swarm, etc).
server mode linked to host 1client mode linked to host 2/data respectivelyFrom the original developer
Unison is a file-synchronization tool for POSIX-compliant systems[...]. It allows two replicas of a collection of files and directories to be stored on different hosts (or different disks on the same host), modified separately, and then brought up to date by propagating the changes in each replica to the other.
Furthermore
Unison has been in use for over 20 years and many people use it to synchronize data they care about.
There are many synchronization tools aimed at keeping remote file systems or directories in sync. This is a very sensible topic because:
While for heavy workloads and where concurrency is required, tools like GlusterFS, BindFS or DRBD are required, for many other workloads (e.g. keeping two volumes in sync where changes are infrequent) there are simpler solutions!
That's where tools like unison and lsyncd come in handy. Stability, predictability, and easy setup are some of the reasons we ended up choosing unison.
Workloads where changes are infrequent and ultimately you only need to keep two volumes in sync.
Some solutions this tool can provide:
In the world of containerization, stateless is king! Unfortunately, some applications like WordPress change their source code during runtime because of the automatic updates or when a user installs themes or plugins.
One way to achieve high-availability is to have two hosts in different regions running a scheduler (e.g. Docker Swarm or Kubernetes) and deploy WordPress on both hosts.
But they need to stay in sync, right? If you expose the WordPress root folder on one volume, it's easy to sync the two servers using this image.
In order not to have problems (like WordPress disabling plugins because they don't exist in one of the hosts or WordPress was recently upgraded) it's important to know that you should run only one instance of WordPress at a time. This is due to its inherent behaviour (believe us, we've been down that road before, it's not great...).
So, if the node WordPress is running on stops serving users, the scheduler will start a new instance on the other node, which will lead to a few seconds of downtime... unfortunately, that's the most you can get without get into conflicts and WordPress issues.
server and the other a client (it doesn't matter which one, they will play nice to each other)/data. You can find an example in the examples folder.Note: take a look at moveyourdigital/docker-wordpress-fpm for ways to replicate MySQL using MariaDB Maxscale.
Some applications use files as their databases, like Bolt. This is the case with Portainer. To achieve high-availability in the case of one of the hosts is down, you can expose the database file to a volume and use that image to perform the synchronizations.
server and the other a client (it doesn't matter which one)/data.Use docker-compose.yml to get an idea of how to use this image. See the examples folder for common implementations.
Content type
Image
Digest
sha256:58061cb5e…
Size
5.9 MB
Last updated
about 4 years ago
docker pull moveyourdigital/unison-sync