mount persistent nfs storage on all docker hosts that use the Moby linux
1.4K
A Simple Docker image to automate mounting a remote NFS share into the Docker host.
docker run -d \
--privileged --pid=host \
--restart=unless-stopped \
-e SERVER=$NFS_SERVER:/ \
-e MOUNT=/host/mount/folder vipconsult/moby-nfs-mount
and then to use it inside a container
docker run -v /host/mount/folder:/container/folder
It support all Docker platforms that use the Moby Linux.
docker service create doesn't support --privileged so we need to run it using swarm-exec which runs a single command on every node cluster including every new node that joins
swarm-exec \
docker run -d \
--privileged --pid=host \
--restart=unless-stopped \
-e SERVER=$NFS_SERVER:/ \
-e MOUNT=/host/mount/folder vipconsult/moby-nfs-mount
https://github.com/mavenugo/swarm-exec
to use it in a service
--mount type=bind,src=/host/mount/folder,dst=/container/folder
nsenter to access the host namespace
install the nfs client on the host
mount the NFS on the hostusing the -e MOUNT env from the run command
inotifywait to output logs for any folder changes
the nfs server should support nfs4 this technique will be replaced by distributed docker volumes plugins and automated docker plugin installation
Content type
Image
Digest
Size
4.8 MB
Last updated
about 9 years ago
docker pull vipconsult/moby-nfs-mount