有谁知道如何使用centos基本映像在docker容器中安装nfs共享?我已经尝试过以下命令:
mount server:/dir /mount/point
并得到下一个错误:
mount.nfs: rpc.statd is not running but is required for remote locking. mount.nfs: Either use '-o nolock' to keep locks local, or start statd. mount.nfs: an incorrect mount option was specified
mount.nfs: rpc.statd is not running but is required for remote locking.
mount.nfs: Either use '-o nolock' to keep locks local, or start statd.
mount.nfs: an incorrect mount option was specified
当我尝试将其与 -o nolock 选项一起使用时,错误是:
mount.nfs: Operation not permitted
对于使用mount,您需要具有此CAP_SYS_ADMIN功能,Docker在创建容器时会丢弃该功能。
mount
CAP_SYS_ADMIN
有几种解决方案:
--cap-add sys_admin
--privileged=true
--cap-add
在主机上挂载NFS共享,并将其作为主机卷传递到容器中:
you@host > mount server:/dir /path/to/mount/point
you@host > docker run -v /path/to/mount/point:/path/to/mount/point
使用Docker卷插件(如Netshare插件)直接将NFS共享作为容器卷挂载:
you@host > docker run \
–volume-driver=nfs \ -v server/dir:/path/to/mount/point \ centos