Nfs Ganesha Docker Image
NFS-Ganesha是一个用户模式的NFS文件服务器,支持NFS v3、4.0、4.1、4.1 pNFS和4.2协议,可并发提供这些协议的文件共享服务。
Description
NFS-Ganesha is a user-mode file server for NFS (v3, 4.0, 4.1, 4.1 pNFS, 4.2)
Supported tags
| Tags | nfs-ganesha | Base |
|---|---|---|
15.X-BUILD, 15.X, 15, latest | 15.X | Debian 13 (trixie) slim |
3.4-BUILD, 3.4 (old, unmaintained) | 3.4 | Debian 10 (buster) slim |
X is the nfs-ganesha minor version, BUILD the build number: see the
https://hub.docker.com/r/izdock/nfs-ganesha/tags for the latest ones.
Images are rebuilt every week with the latest OS security updates, so the 15.X, 15 and latest
tags always point to a patched image; 15.X-BUILD never changes.
Architecture: amd64.
Dockerfile
- https://github.com/ugoviti/izdock-nfs-ganesha/blob/main/Dockerfile
Features
- Small image footprint based on https://hub.docker.com/_/debian/, multi-stage build
- NFS Ganesha binaries are compiled from the upstream official repository (FSAL VFS only, jemalloc allocator)
- Every downloaded source (nfs-ganesha, ntirpc, prometheus-cpp-lite) is pinned and verified by sha256 at build time
- Upstream uses a rolling release model since V8.0: every non-prerelease
Vx.ytag is a stable release - Using https://github.com/krallin/tini as init process
- Many customizable variables to use
What is nfs-ganesha?
Nfs-ganesha is a user-mode file server for NFS (v3, 4.0, 4.1, 4.1 pNFS, 4.2) and for 9P from the Plan9 operating system. It can support all these protocols concurrently. This is an Open Source project with an active community of both company sponsored and independent developers.
How to use this image.
This image only contains nfs-ganesha from https://github.com/nfs-ganesha/nfs-ganesha and from official download repository
Requirements
CAP_SYS_RESOURCE(--cap-add SYS_RESOURCE): ganesha setsPR_SET_IO_FLUSHERat startup to avoid kernel deadlocks when NFS clients run on the same node and memory is low. Without the capability ganesha refuses to start, unlessALLOW_SET_IO_FLUSHER_FAIL=true(protection disabled).CAP_DAC_READ_SEARCH(--cap-add DAC_READ_SEARCH): needed by FSAL VFS (open_by_handle_at).- The process is
ganesha.nfsd, child oftini(PID 1): if ganesha dies the container exits and restarts.
Environment variables
You can change the default behaviour using the following variables (with default values):
: ${EXPORT_PATH:="/exports"} : ${PSEUDO_PATH:="/exports"} : ${EXPORT_ID:=1} : ${PROTOCOLS:=4} # "3, 4" to enable NFSv3 too : ${TRANSPORTS:="TCP"} : ${NFSV4_MINOR_VERSIONS:="0, 1, 2"} : ${SEC_TYPE:="sys"} : ${SQUASH_MODE:="No_Root_Squash"} : ${GRACELESS:=false} : ${GRACE_PERIOD:=90} : ${LEASE_LIFETIME:=60} : ${RECOVERY_BACKEND:="fs"} # fs (state in /var/lib/nfs/ganesha, mount a volume to keep it) | none : ${ACCESS_TYPE:="RW"} : ${CLIENT_LIST:="10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16"} : ${DISABLE_ACL:=false} : ${ANON_USER:="nobody"} : ${ANON_GROUP:="nogroup"} : ${GANESHA_CONFIG:="/etc/ganesha/ganesha.conf"} : ${GANESHA_LOGFILE:="/dev/stdout"} : ${LOG_LEVEL:="INFO"} : ${LOG_COMPONENT:="ALL=INFO;"} : ${ENABLE_NLM:=false} # true by default only if PROTOCOLS contains 3 : ${ENABLE_RQUOTA:=false} : ${STATD_PORT:=662} # rpc.statd (NFSv3 locks) on fixed ports, to expose them with a Service : ${STATD_OUTGOING_PORT:=2020} : ${IDMAPPING_ACTIVE:=false} # AUTH_SYS with numeric owners: no name lookups (true with sec=krb5) : ${MALLOC_CONF:="background_thread:true"} # jemalloc: give freed memory back to the OS also when idle : ${ALLOW_SET_IO_FLUSHER_FAIL:=false} : ${ENABLE_METRICS:=true} # prometheus metrics on http://<host>:9587/metrics : ${MONITORING_PORT:=9587} # performance (measured, see "Performance tuning") : ${READDIR_RES_SIZE:=1048576} # max bytes of an NFSv4 READDIR reply (upstream default 32768) : ${ENABLE_DYNAMIC_METRICS:=false} # per client/export metrics: a mutex on every READ/WRITE/LOOKUP : ${RPC_IOQ_THRDMIN:=2} : ${RPC_IOQ_THRDMAX:=200} # service threads = requests executed at the same time : ${ATTR_EXPIRATION_TIME:=60} : ${TRUST_READDIR_NEGATIVE_CACHE:=false} # metadata cache (MDCACHE) limits : ${MDCACHE_ENTRIES_HWMARK:=100000} : ${MDCACHE_ENTRIES_RELEASE_SIZE:=100} : ${MDCACHE_CHUNKS_HWMARK:=1000} : ${MDCACHE_CHUNKS_LWMARK:=500} : ${MDCACHE_DIR_CHUNK:=128} : ${MDCACHE_LRU_RUN_INTERVAL:=90}
NFSv3
NFSv4 (4.0, 4.1, 4.2) is the default. To serve NFSv3 too set PROTOCOLS="3, 4": rpc.statd and NLM
(NFSv3 locks) are started, every service on a fixed port so that it can be published by a Service:
| Service | Port |
|---|---|
| rpcbind (portmapper) | 111 |
| nfs (v3 and v4) | 2049 |
| mountd | 20048 |
| nlockmgr (NLM) | 32803 |
| status (rpc.statd) | 662 |
| prometheus metrics | 9587 |
rpcbind always runs, also with NFSv4 only: without it ganesha logs Cannot register NFS V4 at
startup and rpcinfo (eg. a liveness probe rpcinfo -n 2049 -t 127.0.0.1 100003 4) does not work.
Performance tuning
Measured with a Linux NFSv4.1 client against 50000 small files and a 20000 entries directory:
READDIR_RES_SIZE=1048576: with the upstream default (32 KiB) a walk of 50000 files takes 2.3s instead of 1.4s andls -lof 20000 files 0.8s instead of 0.5s. 1 MiB is what the Linux client asks for (and what 3.4 used).MDCACHE_ENTRIES_HWMARK=100000(upstream default): a second walk of 80000 files is 8-12% faster than with 50000, for about 60 MiB more memory.ENABLE_DYNAMIC_METRICS=false: no measurable difference with one client, but it removes a mutex and some allocations from every READ/WRITE/LOOKUP; the server metrics are still exported.- No measurable effect:
RPC_IOQ_THRDMIN,TRUST_READDIR_NEGATIVE_CACHE,ATTR_EXPIRATION_TIME. The last two are safe only if nothing changes the exported filesystem outside ganesha: left at their defaults. - Not available on FSAL VFS: delegations, asynchronous writes (COMMIT always runs fsync, which is correct).
Upgrading from 3.x
TRANSPORTSdefault is nowTCP(NFSv4 is TCP only; ganesha >= 14 does not listen for NFS on UDP).- The
RPClog component no longer exists (replaced byXPRT);CACHE_INODE*are nowMDCACHE*. Chunks_HWMarkupstream default went from *** to 1000 (V5.4): directory chunks no longer pin the cache.- NLM, rquota and
rpc.statdare disabled whenPROTOCOLSdoes not include 3. - A log component written twice (e.g. a default plus
LOG_COMPONENT=CLIENTID=DEBUG;) is a fatal config error since ganesha 6: the entrypoint now letsLOG_COMPONENTreplace the defaults. - FSAL VFS ignores
tmpfsexports since ganesha 15 (use a real filesystem forEXPORT_PATH).
Build
Every component version and its sha256 is in https://github.com/ugoviti/izdock-nfs-ganesha/blob/main/versions.env, the single source of truth of the build: nfs-ganesha, the ntirpc and prometheus-cpp-lite of its git submodules, the Debian base image pinned by digest.
git clone https://github.com/ugoviti/izdock-nfs-ganesha.git && cd izdock-nfs-ganesha tools/build.sh # -> izdock/nfs-ganesha:local
Check upstream for new versions and update versions.env (versions and sha256):
tools/make-updates.sh # report only tools/make-updates.sh --apply # update versions.env, then build and test
nfs-ganesha stays on its major version: a new major is only reported. ntirpc and prometheus-cpp-lite
always follow the submodules of the chosen nfs-ganesha release. To keep nfs-ganesha on a given
version add GANESHA_PIN=<version> next to GANESHA_VER in versions.env and run
tools/make-updates.sh --apply.
Build args (docker build --build-arg, or after tools/build.sh):
ALLOCATOR=jemalloc|libc|tcmalloc(defaultjemalloc).ENABLE_ACL=OFF|ON(defaultOFF, as in 3.4): NFSv4 ACLs and the NFSACL protocol of NFSv3. WithONls -lissues one ACL request per file, even withDISABLE_ACL=true: about 10x slower on large directories with NFSv4, about 5x with NFSv3.
Create a Dockerfile in your project
dockerfileFROM izdock/nfs-ganesha # your commands here
Then, run the commands to build and run the Docker image:
console$ docker build -t nfs-ganesha . $ docker run -dit --name nfs-ganesha --cap-add SYS_RESOURCE --cap-add DAC_READ_SEARCH -p 2049:2049 nfs-ganesha
Without a Dockerfile
If you don't want to include a Dockerfile in your project, it is sufficient to do the following:
$ docker run -dit --name my-nfs --cap-add SYS_RESOURCE --cap-add DAC_READ_SEARCH -p 2049:2049 -v "/tmp/testvolme":/data -e EXPORT_PATH=/data izdock/nfs-ganesha
Configuration
To customize the configuration of nfs-ganesha, just change the default variables:
docker run -dit --name my-nfs --cap-add SYS_RESOURCE --cap-add DAC_READ_SEARCH -p 2049:2049 -v "/tmp/testvolme":/data -e EXPORT_PATH=/data -e CLIENT_LIST="192.168.1.1, 192.168.1.23" -e LOG_LEVEL=DEBUG izdock/nfs-ganesha
Quick reference
-
Where to get help: InitZero Corporate Support
-
Where to file issues: https://github.com/ugoviti
-
Maintained by: https://github.com/ugoviti
-
Supported architectures: [
amd64] -
Supported Docker versions: https://github.com/docker/docker-ce/releases/latest (down to 1.6 on a best-effort basis)
License
View https://www.apache.org/licenses/ and http://php.net/license/index.php and for the software contained in this image.
As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).
Some additional license information which was able to be auto-detected might be found in https://github.com/docker-library/repo-info/tree/master/repos/httpd.
As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.
izdock 命名空间的其他可用镜像:
镜像拉取方式
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
轩辕镜像加速拉取命令点我查看更多 nfs-ganesha 镜像标签
DockerHub 原生拉取命令
用户好评
来自真实用户的反馈,见证轩辕镜像的优质服务