A docker volume container using Unison for fast two-way folder sync. Created as an alternative to slow docker for mac volumes on OS X.
This image is trying to be as minimal as possible and it only weights 14.41MB.
The docker image is available on Docker Hub: registry.hub.docker.com/u/whiteplus/unison/
First, you can launch a volume container exposing a volume with Unison.
$ CID=$(docker run -d -p 5000:5000 -e UNISON_DIR=/data whiteplus/unison)You can then sync a local folder to $UNISON_DIR (default value: /data) in the container with:
$ unison . socket://<docker>:5000/ -auto -batchNext, you can launch a container connected with the volume under /data.
$ docker run -it --volumes-from $CID ubuntu /bin/shThis container has few envs that you can alter.
UNISON_DIR - This is the directory which receives data from unison inside the container.
This is also the directory which you can use in other containers with volumes_from directive.
UNISON_GID - Group ID for the user running unison inside container.
UNISON_UID - User ID for the user running unison inside container.
UNISON_USER - User name for the sync user ( UID matters more )
UNISON_GROUP - Group name for the sync user ( GID matters more )
If you are using Docker Compose to manage a dev environment, use the volumes_from directive.
The following docker-compose.yml would mount the /var/www/project folder from the unison container inside your mywebserver container.
mywebserver:
build: .
volumes_from:
- unison
unison:
image: whiteplus/unison
environment:
- UNISON_DIR=/var/www/project
- UNISON_UID=10000
- UNISON_GID=10000
ports:
- "5000:5000"
volumes:
- /var/www/projectYou can then sync a local folder, using the unison client, to /unison in the container with:
$ unison . socket://<docker>:5000/ -ignore 'Path .git' -auto -batchYou can use -repeat watch to sync everytime when files change:
$ unison . socket://<docker>:5000/ -repeat watch -ignore 'Path .git' -auto -batchNOTE: In order to use -repeat option you need to install unison-fsmonitor.
Thanks for onnimonni for showing me how to use unison with docker.
This docker image is licensed under GPLv3 because Unison is licensed under GPLv3 and is included in the image. See LICENSE.