这里写自定义目录标题
Docker环境磁盘映射【win7可以用】
1、【宿主机下安装】root用户下Samba软件安装
yum install samba samba-client samba-swat

2、【宿主机下安装】检查Samba安装的版本
rpm -qa | grep samba
3、【宿主机下安装】启动smb服务
systemctl start smb.service
服务无法启动报错:Job for smb.service failed because the control process exited with error code
然后testparm –v 提示没共享,需要先执行第6步
4、【宿主机下安装】查看smb服务状态
systemctl status smb.service
5、【宿主机下安装】设置smb服务开机启动
chkconfig --level 35 smb on
chkconfig --level 35 nmb on
6、【宿主机下安装】更改samba配置文件
“/etc/samba/smb.conf”,参照如下修改(修改后可以执行testparm -v命令,检查配置文件是否正确)
[global]
workgroup = SAMBA
server string = Samba Server Version %v
log file = /var/log/samba/log.%m
max log size = 500
security = user
passdb backend = tdbsam
guest account = nobody
printing = cups
printcap name = cups
load printers = yes
cups options = raw
[homes]
comment = Home Directories
valid users = %S, %D%w%S
browseable = No
inherit acls = Yes
writable = yes
[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes
[netlogon]
comment = Network Logon Service
path = /var/lib/samba/netlogon
guest ok = yes
writable = no
share modes = no
[Profiles]
path = /var/lib/samba/profiles
browseable = no
guest ok = yes
7、【宿主机下安装】新增smb用户
(1)该smb的用户需要在宿主机中存在(建议新建file用户进行磁盘映射)
useradd file –d /home/file –m;
echo “file” | passwd –stdin file;
chmod –R 777 /home/file
(2)需要输入smb用户的用户名和密码(建议设置为file, file),windows映射后登陆需要
pdbedit -L 查看smb用户
pdbedit -a file 新建smb用户file
8、【宿主机下安装】重启samba服务
systemctl restart smb.service
9、【docker下安装】
Root用户在home下创建一个file文件夹,然后权限改为777
mkdir /home/file
chmod -R 777 /home/file
10、【docker下安装】
docker环境或者其他linux环境挂载共享盘
将docker下/home/file目录挂载到宿主机的file目录下。
mount -o username=file,password=file //192.168.39.151/file /home/file
df -h查看挂载
11、【windows】
windows右键计算机,点击映射网络驱动,驱动器选择就是需要映射的盘符,文件夹填入对应服务器的\IP\用户名,例如\127.0.0.1\file,点击完成,属于映射的用户名和密码(例如: file, file)
10、完成后即可看到已经映射到了对应的盘符
物理机环境磁盘映射【win7可以用】
1、root用户下Samba软件安装
yum install samba samba-client samba-swat
2、检查Samba安装的版本
rpm -qa | grep samba
3、启动smb服务
systemctl start smb.service
服务无法启动报错:Job for smb.service failed because the control process exited with error code
然后testparm –v 提示没共享,需要先执行第6步
4、查看smb服务状态
systemctl status smb.service
5、设置smb服务开机启动
chkconfig --level 35 smb on
chkconfig --level 35 nmb on
6、更改samba配置文件
“/etc/samba/smb.conf”,参照如下修改(修改后可以执行testparm -v命令,检查配置文件是否正确)
[global]
workgroup = SAMBA
server string = Samba Server Version %v
log file = /var/log/samba/log.%m
max log size = 500
security = user
passdb backend = tdbsam
guest account = nobody
printing = cups
printcap name = cups
load printers = yes
cups options = raw
[homes]
comment = Home Directories
valid users = %S, %D%w%S
browseable = No
inherit acls = Yes
writable = yes
[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes
[netlogon]
comment = Network Logon Service
path = /var/lib/samba/netlogon
guest ok = yes
writable = no
share modes = no
[Profiles]
path = /var/lib/samba/profiles
browseable = no
guest ok = yes
7、新增smb用户
(1)该smb的用户需要在linux下存在(建议新建file用户进行磁盘映射)
useradd file –d /home/file –m;
echo “file” | passwd –stdin file;
chmod –R 777 /home/file
(2)需要输入smb用户的用户名和密码(建议设置为file, file),windows映射后登陆需要
pdbedit -L 查看smb用户
pdbedit -a file 新建smb用户file
8、重启samba服务
systemctl restart smb.service
9、【windows】
windows右键计算机,点击映射网络驱动,驱动器选择就是需要映射的盘符,文件夹填入对应服务器的\IP\用户名,例如\192.168.39.29\root,点击完成,属于映射的用户名和密码(例如: file, file)
10、完成后即可看到已经映射到了对应的盘符
参考资料:
https://www.cnblogs.com/akidongzi/p/6610180.html
https://blog.youkuaiyun.com/he90227/article/details/38304209
待解决问题:
1、 win10操作系统未能连接服务器