A Docker volume plugin to mount a ZooKeeper tree as a filesystem
A Docker volume as a ZooKeeper tree volume plugin
To install just type:
docker plugin install smokserwis/zookeeper-volume
docker plugin enable smokserwis/zookeeper-volume
Note that if you keep your Docker root in other place than/var/lib/docker
, best install from source, before which
change the path in config.json
, or alternatively symlink this location to your target.
If you logs are stored somewhere else than /var/log
, you best
do it too. Or symlink, it’s your choice.
Just check this repo out on a normal UNIX platform (sorry, only UNIXes supported for the time being)
and invoke build.sh
.build.sh
will automatically install and enable the plugin.
If you set the env DEBUG
during build.sh
‘s run,
debugging mode will be enabled on the plugin. You can later change it.
To enable debug logs just type:
docker plugin set smokserwis/zookeeper-volume DEBUG=1
They will be dumped at /var/log/daemon.log
or the usual place where your Docker drops it’s logs.
Note that setting the env DEBUG
during a run of build.sh
will
automatically set the variable to 1.
The variable is kept at default 0 in config.json
.
Note that the output from zookeeper-fuse is in:
/var/log/zookeeper-volume/volumename.stdout.txt
and/var/log/zookeeper-volume/volumename.stderr.txt
To define a volume just type
docker volume create -d smokserwis/zookeeper-volume -ohosts=192.168.2.237:2181 -opath=/zk-child zookeeper
The thing that you provide in hosts
option is a ZooKeeper connection string.
This is the lists of hosts with ports separated with a comma.
As so, it is mandatory to provide port number.
Volume must have at least a single option:
host
for an address and a port nameor
hostsfor multiple of those, separated by a
,`Other options can be optionally given:
path
: zookeeper path to mount as rootmode
: zookeeper-fuse access modeDIR
or FILE
.auth
: zookeeper authentication string (by default none given)Special thanks to borowskk’s zookeeper-fuse,
without which this plugin wouldn’t happen to exist.
Since zookeeper-fuse’s default access modes of DIR and FILE do not permit to use ZooKeeper systems as a valid filesystem (ie. once you create a file it becomes a directory) and does not support symlinks I have extended zookeeper-fuse to add symlink support and if you create a file it stays a file. Basically it remembers what you have done while creating that file. I’ve also filed a pull request.
Note however that cache invalidation is not yet supported, so if you process files with new names you are going to run into trouble. If you however keep on processing the same files, you should be OK.
What hybrid mode supports:
__symlinks__
is an invalid file name, since this is the file in which symlink information is stored at the root.cp
is supportedmv
is supported for files only. Moving a directory is a ENOSYS.Please note that the default mode in which
smokserwis/zookeeper-volume mounts volumes isHYBRID
not DIR
or FILE
.
In HYBRID mode syscalls lock
and flock
are mapped to no-ops. They
will create a file for all it’s worth.
It works much better if you ls -R
the entire mounted directory prior to using files from there.
Keep in mind that the maximum file size is limited by
zookeeper-fuse
and is currently set to 128 kB.
mv
-ing fileslock
, flock
, release
,releasedir
and access
addedHYBRID
instead of DIR