NFS Mounted Volume Plugin for Docker/Swarm
1.5K
This is a managed Docker volume plugin to allow Docker containers to access an NFS mount without installing NFS on the host.
/sys/fs/cgroup folder of the host and expose it to the plugin as read only. /sys/fs/cgroup is needed for systemd integration to work.--alias when installing the plugin.In order to not make this a free-for-all, only the device option is recognized. Any mount options need to be set up as part of the plugin. Multiple copies of the plugin can co-exist with different options under different aliases.
The plugin supports the following settings:
DEFAULT_NFSOPTS this corresponds to the default value -o parameter of the mount command. It will be treated as a single string so it cannot inject the mount points or devices.When installinng, it is recommended that a PLUGINALIAS is specified so that you would know what it is for and can easily control multiple copies of it. This can be done in an automated fashion as:
docker plugin install --alias PLUGINALIAS \
mochoa/nfs-volume-plugin \
--grant-all-permissions --disable
docker plugin set PLUGINALIAS DEFAULT_NFSOPTS=hard,proto=tcp,nfsvers=4,intr
docker plugin enable PLUGINALIAS
Example in docker-compose.yml:
volumes:
sample:
driver: PLUGINALIAS
driver_opts:
device: "server1:/share_name"
name: "whatever_name_you_want"
Which yields the following command
mount -t nfs -o hard,proto=tcp,nfsvers=4,intr server1:/share_name /generated_mount_point
This is an example of mounting and testing a store outside the swarm. It is assuming the share is called 192.168.1.1:/mnt/routerdrive/nfs.
docker plugin install mochoa/nfs-volume-plugin --grant-all-permissions
docker plugin enable mochoa/nfs-volume-plugin
docker volume create -d mochoa/nfs-volume-plugin --opt device=192.168.1.1:/mnt/routerdrive/nfs --opt nfsopts=hard,proto=tcp,nfsvers=3,intr,nolock nfsmountvolume
docker run -it -v nfsmountvolume:/mnt alpine
Content type
Plugin
Digest
Size
79.9 MB
Last updated
over 5 years ago
docker plugin install mochoa/nfs-volume-plugin