docker安装samba
# 一、docker安装samba
# 1.准备
#新建文件夹
mkdir -p /docker/samba/conf
#拉取镜像
docker pull dockurr/samba
1
2
3
4
2
3
4
# 2.配置文件
在/docker/samba/conf
下
vi smb.default
[global]
security = user
server min protocol = SMB2
# disable printing services
load printers = no
printing = bsd
printcap name = /dev/null
disable spoolss = yes
max xmit = 65535
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=131072 SO_SNDBUF=131072
min receivefile size = 16384
use sendfile = yes
aio read size = 16384
aio write size = 16384
vfs objects = catia fruit streams_xattr
[data]
path = /data
comment = Shared
valid users = mx #有访问权限的用户 可以是用户名 也可以是分组名
browseable = yes
writable = yes
read only = no
force user = root
force group = root
fruit:time machine = yes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 配置文件说明
配置示例
[global]
security = user
server min protocol = SMB2
# disable printing services
load printers = no
printing = bsd
printcap name = /dev/null
disable spoolss = yes
#max xmit = 65535
#socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=131072 SO_SNDBUF=131072
#min receivefile size = 16384
#use sendfile = yes
#aio read size = 16384
#aio write size = 16384
vfs objects = catia fruit streams_xattr
[disk1]
path = /disk1
comment = Shared
valid users = yanchun #有访问权限的用户 可以是用户名 也可以是分组名
browseable = yes
writable = yes
read only = no
force user = root
force group = root
[disk2]
path = /disk2
comment = Shared
valid users = yanchun
browseable = no #隐藏当前文件夹
writable = yes
read only = no
force user = root
force group = root
fruit:time machine = yes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# 3、启动
docker run -d --restart always --name samba -p 445:445 \
-v "/docker/samba/data:/data" \
-v "/docker/samba/conf:/etc/samba" \
-e "USER=mx" -e "PASS=5tgb%TGB" \
dockurr/samba
1
2
3
4
5
2
3
4
5
说明
/docker/samba/data
是宿机路径 需要共享出去的文件夹/docker/samba/conf
宿机配置文件路径
# 4.账号操作
# 1).增加账号
# 进入 Samba 容器
docker exec -it samba /bin/bash
# 新增系统用户(假设用户名为 admin)
useradd -M -s /sbin/nologin admin
# 为新增的系统用户设置 Samba 密码
smbpasswd -a admin
#添加分组
# 将 admin 添加到 smb 组
usermod -aG smb admin
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
# 2).删除账号
# 删除系统用户
userdel <username>
1
2
2
# 3).查看账号
# 查看 Samba 用户列表
pdbedit -L
1
2
2
上次更新: 2024/11/02, 15:12:15