Skip to content
This repository has been archived by the owner on Jun 27, 2020. It is now read-only.

Dockerized NFS server - NFS server as a docker container

Notifications You must be signed in to change notification settings

wakonp/dockerized_nfs_server

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dockerized NFS Server

Table of Contents

Prerequisites

Get docker !

Before you start

  • This was originally created for the following purposes: development, testing and playground, as i develop locally on my pc without the need to have a real nfs server while on train or plane and without dirtying my pc with non-essential packages. I haven't tested it performance-wise nor using it in production.
  • This nfs server is currently not secured and using docker privileged flag in order to allow mount NFS filesystem, export it as docker volume (also for use by other containers) and overcome security modules limitations (e.g. 'selinux', 'appArmor'..etc).
    It can be run in more secured mode, if you'll handle those limitations by yourself and then start server by just running:
    docker run -d --name mynfs --cap-add=SYS_ADMIN erezhorev/dockerized_nfs_server
    for example, the following command will work on ubuntu overriding appArmor's docker policy:
    docker run -d --name mynfs --cap-add=SYS_ADMIN --security-opt apparmor:unconfined erezhorev/dockerized_nfs_server.

Start server

Activate the server by running the script start.sh.
For your convenience, it can also be sourced (e.g. source start.sh) which will set the environment variable MYNFSIP with the server's ip.

Behind stage it will automatically pull the docker image from Docker hub and start the nfs server container named 'mynfs' with the default export point: /exports.
(Docker internal run command: docker run -d --name mynfs --privileged erezhorev/dockerized_nfs_server)

Set your own exports

Optional arguments are allowed and transformed to export points with the default export (/exports) as their root base path.

  • Legal arguments form:
    start.sh share1 /share2 /some/share3 some/more/share4.

  • Arguments are allowed to include preceding Slash-'/' but its just the same as without it, each given argument transforms to an active export point under /exports.
    example: share1 /share2 -> /exports/share1 /exports/share2

Stop server

Run: stop.sh (or docker stop mynfs ; docker rm mynfs).
Note it also removes the server container with all its data!
To stop and preserve data, just run docker stop mynfs instead.

Troubleshoot & Debug

Server's status

Run status.sh as it includes the following info:
export points, server's stdout and running processes.

Test mount

Run: mount -v -t nfs -o proto=tcp,port=2049 [nfs server ip]:/exports/share1 /mnt/target_dir

Get inside container's shell

Run: docker exec -ti mynfs bash

And then, for example, you may run netstat -tl to see if nfs is there.

Make sure native host kernel support nfs

Run: lsmod | grep nfsd to see if the kernel module is there.

The nfs service of the docker container relies on the kernel of the native host to provide the kernel-level nfs support. If your nfs service is not up correctly, please make sure your native kernel does support nfs service.

General Info

  • Based on ubuntu nfs-kernel-server.
  • Current export point options are hard coded and consist of the following: rw,sync,insecure,no_subtree_check,no_root_squash
  • Docker hub reference

About

Dockerized NFS server - NFS server as a docker container

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%