Lsyncd for docker
Lsyncd (Live Syncing (Mirror) Daemon) is a tool that watches a local directory trees event monitor interface (inotify or fsevents).
It aggregates and combines events for a few seconds and then spawns one (or more) process(es) to synchronize the changes.
This docker image was build in order to increase performance of docker mounted folders in non Linux environment. Currently, all Docker solutions in non Linux
suffers from very bad reading / writing performance in mounted folders, whether they use vboxfs, NFS, whatever...
This docker image helps in the process of creating a replica in container of the directory mounted.
License: GPLv2 or any later GPL version.
The mounted folders in the container must be abled to emit
fsevents. Traditional VM mounts doesn't support this. You can have a look at
dinghy project that includes a way to support this in the virtual machine with their daemon
How to use
Here is an example on how to use it with a docker-compose file. The scenario illustrates a way to sync source code in real-time from the host inside
the container and get the output generated by the execution of the code back to the host.
version: '2' services: app: volumes: - ./src:/src.mounted - ./output:/output.mounted - /src - /output lsyncd: build: mickaelperrin/lsyncd environment: - SOURCES=/src.mounted:/output - DESTINATIONS=/src:/output.mounted - EXCLUDES=.git:.svn volumes_from: - app
The local folders
./output are mounted in the
app container as respectively
The app container inits also two aditionnal volumes
The lsyncd container is configured to provides a real-time sync between the
/src.mounted to the
/src folder and the
Configuration is done through environment variables:
SOURCESlists the source folder from which the data is synced. Multiple sources folders can de listed by separating them with the
DESTINATIONSlists the destination folder where data will be copied. You must provide a destination folder for each source folder.
EXCLUDESadd the ability to add
Source code is available on GitHub: https://github.com/mickaelperrin/docker-lsyncd
Besides the usual disclaimer in the license, we want to specifically emphasize that the authors, and any organizations the authors are associated with, can not be held responsible for data-loss caused by possible malfunctions of Lsyncd.