Skip to content

Instantly share code, notes, and snippets.

@saggie
Last active November 12, 2022 01:14
Show Gist options
  • Save saggie/650ea042ec294967784dfd7ade519a1b to your computer and use it in GitHub Desktop.
Save saggie/650ea042ec294967784dfd7ade519a1b to your computer and use it in GitHub Desktop.
Running a NFS Server using Docker

Running a NFS Server using Docker

Dockerで検証用のNFSサーバをさくっと起動する方法

Server side

Preparation

$ mkdir -p /opt/nfs
$ echo 'Hello!' > /opt/nfs/hello.txt

Run

$ docker run --rm -d \
  -v /opt/nfs:/export \
  -v /lib/modules:/lib/modules:ro \
  -e NFS_EXPORT_0='/export *(insecure,rw,sync,all_squash,no_subtree_check,fsid=0)' \
  --privileged \
  -p 2049:2049 \
  erichough/nfs-server

Client side

On Linux/macOS:

$ mkdir ~/nfs_tmp
$ mount -t nfs -o vers=4.0 __NFS_SERVER_ADDRESS__:/ ~/nfs_tmp
$ cat ~/nfs_tmp/hello.txt
Hello!
$ umount ~/nfs_tmp

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment