Sign inSign up

vipconsult/moby-nfs-mount

By vipconsult

•Updated about 9 years ago

mount persistent nfs storage on all docker hosts that use the Moby linux

Image
2

1.4K

vipconsult/moby-nfs-mount repository overview

A Simple Docker image to automate mounting a remote NFS share into the Docker host.

⁠Usage

Usage Example on Amazon AWS

docker run -d \
    --privileged --pid=host \
    --restart=unless-stopped \
    -e SERVER=$NFS_SERVER:/  \
    -e MOUNT=/host/mount/folder vipconsult/moby-nfs-mount
  • SERVER : the remote NFS server (it is set for nfs4)
  • MOUNT : local host folder used for the mounting

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 for Mac
  • Docker for AWS
  • Docker for Windows (unsure)
  • Should work on any Alpine docker host
⁠To mount it on all swarm nodes run using :

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
⁠Here is how it works:

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

⁠NOTES:

the nfs server should support nfs4 this technique will be replaced by distributed docker volumes plugins and automated docker plugin installation

Tag summary

Content type

Image

Digest

Size

4.8 MB

Last updated

about 9 years ago

docker pull vipconsult/moby-nfs-mount