-v /app/storage/nfs:/nfsshare 
 -e NFS_EXPORT_0=‘/nfsshare *(rw,sync,no_root_squash,no_all_squash,no_subtree_check,nohide,crossmnt)’ 
 -p 2049:2049 -p 2049:2049/udp 
 -p 111:111 -p 111:111/udp 
 -p 32765:32765 -p 32765:32765/udp 
 -p 32767:32767 -p 32767:32767/udp 
 erichough/nfs-server

在Ubuntu宿主机上安装nfs客户端工具

$ sudo apt install nfs-client
 $ showmount -e 10.20.176.101
 Export list for 10.20.176.101:
 /nfsshare *
步骤 03.手动挂载nfs到指定磁盘目录中。

mount -v -t nfs -o ro,nfsvers=3,nolock,proto=udp,port=2049 10.20.176.101:/nfsshare /mnt/nfs

$ sudo mkdir -vp /app/storage/nfs
 $ sudo docker run -it --name samba -p 139:139 -p 445:445 
 -e TZ=Etc/UTC 
 -v /app/storage/nfs:/share 
 -d dperson/samba -p 
 -u “iuser;123456” 
 -s “myshare;/share;yes;no;yes”
**步骤 02.Windows 中挂载 samba-server**

方式1.

\10.20.176.101\myshare

方式2.

C:\Users\WeiyiGeek>net use J: \10.20.176.101\myshare “123456” /USER:iuser /PERSISTEN:yes

命令成功完成。

C:\Users\WeiyiGeek>net use | findstr iuser

OK J: \10.20.176.101\myshare Microsoft Windows Network

可用 ENVIRONMENT VARIABLES:
  • CHARMAP - As above, configure character mapping
  • GENERIC - As above, configure a generic section option (See NOTE3 below)
  • GLOBAL - As above, configure a global option (See NOTE3 below)
  • IMPORT - As above, import a smbpassword file
  • NMBD - As above, enable nmbd
  • PERMISSIONS - As above, set file permissions on all shares
  • RECYCLE - As above, disable recycle bin
  • SHARE - As above, setup a share (See NOTE3 below)
  • SMB - As above, disable SMB2 minimum version
  • TZ - Set a timezone, IE EST5EDT
  • USER - As above, setup a user (See NOTE3 below)
  • WIDELINKS - As above, allow access wide symbolic links
  • WORKGROUP - As above, set workgroup
  • USERID - Set the UID for the samba server’s default user (smbuser)
  • GROUPID - Set the GID for the samba server’s default user (smbuser)
  • INCLUDE - As above, add a smb.conf include
官方地址: https://www.samba.org/  
 参考地址: https://hub.docker.com/r/dperson/samba  
 Github地址: https://github.com/dperson/samba/issues


**步骤 03.Linux 中挂载 samba-server**  
 首先,我们需要安装相关 samba 挂载依赖 cifs-utils 服务与 smbclient 命令

apt install cifs-utils smbclient -y

其次,若有密码请创建一个配置文件,存储用户名和密码

username=iuser
password=123456

然后,创建挂载的目录并挂载samba

使用mount命令进行挂载

mount -t cifs -o vers=3.0,credentials=/etc/.smbcredentials //10.20.176.101/myshare /media/share

开机自动挂载(optional)

vim /etc/fstab
 //10.20.176.101/myshare /myshare cifs rw,relatime,vers=3.0,sec=ntlmssp,cache=strict,username=root,domain=SMBALIBABACLOUD,uid=0,noforceuid,gid=0,noforcegid,addr=10.41.40.92,file_mode=0755,dir_mode=0755,nounix,serverino,mapposix,rsize=1048576,wsize=1048576,echo_interval=60,actimeo=1 1 1
$ smbclient -L 10.20.176.101 -U root
 $ df -Th
 $ mount -l
 //10.20.176.101/myshare on /myshare type cifs (rw,relatime,vers=3.0,sec=ntlmssp,cache=strict,username=root,domain=SMBALIBABACLOUD,uid=0,noforceuid,gid=0,noforcegid,addr=10.41.40.92,file_mode=0755,dir_mode=0755,nounix,serverino,mapposix,rsize=1048576,wsize=1048576,echo_interval=60,actimeo=1)
温馨提示: 若出现挂载失败可以通过查看日志 `tail -f /var/log/kern.log`


温馨提示: 若samba客户端连接报`NT_STATUS_INVALID_NETWORK_RESPONSE`错误解决办法,在samba服务端添加支持最小协议`server min protocol = LANMAN1`, 然后重启smb服务,客户端便可重新连接成功。

问题原因:

The defaults of ‘client min protocol’ and ‘server min protocol’ have been changed to SMB2_02.
 This means clients without support for SMB2 or SMB3 are no longer able to connect to smbd (by default).
 It also means client tools like smbclient and other, as well as applications making use of libsmbclient are no longer able to connect to servers without SMB2 or SMB3 support (by default).
 It’s still possible to allow SMB1 dialects, e.g. NT1, LANMAN2 and LANMAN1 for client and server, as well as CORE and COREPLUS on the client.