目前用客厅做的HTPC上运行的ubuntu,跑了aria+h5ai,但是发现回家后内网不能用samba共享文件,所以考虑装个sabma。但是,samba复杂的配置导致非常恶心,一旦需要重装后非常麻烦,所以就用docker实现。(不得不说以下docker真是好东西啊)
抽取镜像
这个是dockerhub上评价比较高的,github地址:https://github.com/dperson/samba
docker pull dperson/samba
建立服务
docker run -it --name samba -p 139:139 -p 445:445 \
-v /home:/mount -d dperson/samba -u "www;overkill" -s "www;/mount/;yes;no;no;all;none"
除了docker中正常的参数,其他的参数解释如下:
- /home是需要共享的本地文件,就是在宿主机中的
- “www;overkill”是建立的用户名和密码
- www;/mount/;yes;no;no;all;none 解释含义:其中guest应该就是可以控制匿名共享,但是还没实验
最终代码
docker run -it --name samba2 -p 139:139 -p 445:445 \
-v /root/disk/plex-share/data:/mount -d dperson/samba -s "www;/mount/;yes;no;yes;all;none"
2019.3.1更新 增加官方对参数的全部解释
" setup character mapping for file/directory names
required arg: "from:to" character mappings separated by ','
-g "parameter" Provide global option for smb.conf
required arg: "parameter" - IE: -g "log level = 2"
-i "path" Import smbpassword
required arg: "path" - full file path in container
-n Start the 'nmbd' daemon to advertise the shares
-p Set ownership and permissions on the shares
-r Disable recycle bin for shares
-S Disable SMB2 minimum version
-s "name;[;browse;readonly;guest;users;admins;writelist;comment]"
Configure a share
required arg: "
"
<path> path to share
NOTE: for the default values, just leave blank
[browsable] default:'yes' or 'no'
[readonly] default:'yes' or 'no'
[guest] allowed default:'yes' or 'no'
[users] allowed default:'all' or list of allowed users
[admins] allowed default:'none' or list of admin users
[writelist] list of users that can write to a RO share
[comment] description of share
-u "<username;password>[;ID;group]" Add a user
required arg: "<username>;<passwd>"
<username> for user
<password> for user
[ID] for user
[group] for user
-w "
required arg: "<workgroup>"
<workgroup> for samba
-W Allow access wide symbolic links
-I Add an include option at the end of the smb.conf
required arg: "<include file="" path="">"
<include file="" path=""> in the container, e.g. a bind mount
The 'command' (if provided and valid) will be run instead of samba
">
sudo docker run -it --rm dperson/samba -h
Usage: samba.sh [-opt] [command]
Options (fields in '[]' are optional, '<>' are required):
-h This help
-c "<from:to>" setup character mapping for file/directory names required arg: <span class="hljs-string">"<from:to>"</span> character mappings separated <span class="hljs-keyword">by</span> <span class="hljs-string">','</span>
-g "" Provide global option for smb.conf
required arg: <span class="hljs-string">"<parameter>"</span> - IE: -g <span class="hljs-string">"log level = 2"</span>
-i "" Import smbpassword
required arg: <span class="hljs-string">"<path>"</span> - full file path <span class="hljs-keyword">in</span> container
-n Start the 'nmbd' daemon to advertise the shares
-p Set ownership and permissions on the shares
-r Disable recycle bin for shares
-S Disable SMB2 minimum version
-s "<name;/path>[;browse;readonly;guest;users;admins;writelist;comment]"
Configure a share
required arg: <span class="hljs-string">"<name>;</path>"</span>
<name> <span class="hljs-keyword">is</span> how it<span class="hljs-string">'s called for clients
<path> path to share
NOTE: for the default values, just leave blank
[browsable] default:'</span><span class="hljs-literal">yes</span><span class="hljs-string">' or '</span><span class="hljs-literal">no</span><span class="hljs-string">'
[readonly] default:'</span><span class="hljs-literal">yes</span><span class="hljs-string">' or '</span><span class="hljs-literal">no</span><span class="hljs-string">'
[guest] allowed default:'</span><span class="hljs-literal">yes</span><span class="hljs-string">' or '</span><span class="hljs-literal">no</span><span class="hljs-string">'
[users] allowed default:'</span>all<span class="hljs-string">' or list of allowed users
[admins] allowed default:'</span>none<span class="hljs-string">' or list of admin users
[writelist] list of users that can write to a RO share
[comment] description of share
-u "<username;password>[;ID;group]" Add a user
required arg: "<username>;<passwd>"
<username> for user
<password> for user
[ID] for user
[group] for user
-w "" Configure the workgroup (domain) samba should use
required arg: "<workgroup>"
<workgroup> for samba
-W Allow access wide symbolic links
-I Add an include option at the end of the smb.conf
required arg: "<include file path>"
<include file path> in the container, e.g. a bind mount
The 'command' (if provided and valid) will be run instead of samba
</username;password>