如何在没有端口映射器的 Ubuntu docker 实例中 运行 Ubuntu NFS V4 内核服务器?

How to run an Ubuntu NFS V4 kernel server in an Ubuntu docker instance without port mapper?

我需要在 docker 中以纯 V4 模式运行 NFS 服务器,即没有 portmapper 端口 111。(原因:Docker 中的 NFS 服务器在 Windows 中的 WSL2 中。)

我找到了如何在未打开端口 111 的情况下操作 Ubuntu 默认内核 NFS 服务器的说明:

来自https://peteris.rocks/blog/nfs4-single-port/

$ sudo vim /etc/default/nfs-kernel-server
...
RPCMOUNTDOPTS="--no-nfs-version 2 --no-nfs-version 3 --nfs-version 4 --no-udp"
RPCNFSDOPTS="--no-nfs-version 2 --no-nfs-version 3 --nfs-version 4 --no-udp"
...
$ sudo systemctl disable --now rpcbind.service rpcbind.socket
$ sudo systemctl mask rpcbind.service rpcbind.socket

但是,此说明依赖于命令“systemctl disable/mask”,这些命令在我的 Ubuntu docker 映像中不可用,因为 [=] 中自然没有 systemd 或 init 45=]。当我在 /etc/default/kernel-server 中排除版本 2 和 3 并启动 nfs 时,我收到错误消息:

Not starting: portmapper is not running

问题:

非常感谢。

解决方案:

A) 在初始化脚本中禁用 rpcbind 检查

sudo vim /etc/init.d/nfs-kernel-server

去掉8行附近#看看rpcbind是不是运行ning ... if ...fi

B) 启动摇杆时使用--privileged 运行