Loading... 目前用客厅做的HTPC上运行的ubuntu,跑了**aria+h5ai**,但是发现回家后**内网不能用samba共享文件**,所以考虑装个**sabma**。但是,samba复杂的配置导致非常恶心,一旦需要重装后非常麻烦,所以就**用docker实现**。(不得不说以下docker真是好东西啊) <!--more--> <div class="tip inlineBlock warning"> 强烈不推荐直接配置samba,因为过程真的太复杂了,我至今有也没有找到合适的一键包。 </div> ## 抽取镜像 这个是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: " <name>;</name> " <name> is how it's called for clients <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 "<workgroup>" 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 "><pre class="vditor-wysiwyg__pre" style="display:none"><code>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: "<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;/path>[;browse;readonly;guest;users;admins;writelist;comment]" Configure a share required arg: "<name>;</path>" <name> is how it's called for clients <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 "<workgroup>" 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 </code></pre><pre class="vditor-wysiwyg__preview" data-render="1"><div class="vditor-copy"><textarea></textarea><span aria-label="复制" onmouseover="this.setAttribute('aria-label', '复制')" class="vditor-tooltipped vditor-tooltipped__w" onclick="this.previousElementSibling.select();document.execCommand('copy');this.setAttribute('aria-label', '已复制')"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32px" height="32px"> <path d="M28.681 11.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-11.5c-1.379 0-2.5 1.121-2.5 2.5v23c0 1.378 1.121 2.5 2.5 2.5h19c1.378 0 2.5-1.122 2.5-2.5v-15.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 9.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268v0zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-19c-0.271 0-0.5-0.229-0.5-0.5v-23c0-0.271 0.229-0.5 0.5-0.5 0 0 11.499-0 11.5 0v7c0 0.552 0.448 1 1 1h7v15.5zM18.841 1.319c-1.612-1.182-2.393-1.319-2.841-1.319h-11.5c-1.378 0-2.5 1.121-2.5 2.5v23c0 1.207 0.86 2.217 2 2.45v-25.45c0-0.271 0.229-0.5 0.5-0.5h15.215c-0.301-0.248-0.595-0.477-0.873-0.681z"></path> </svg></span></div><code style="max-height: 640px;" class="hljs coffeescript vditor-linenumber">sudo docker run -it --rm dperson/samba -h Usage: samba.sh [-opt] [command] Options (fields <span class="hljs-keyword">in</span> <span class="hljs-string">'[]'</span> are optional, <span class="hljs-string">'<>'</span> are required): -h This help -c <span class="hljs-string">"<from:to>"</span> setup character mapping <span class="hljs-keyword">for</span> 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 <span class="hljs-string">"<parameter>"</span> Provide <span class="hljs-built_in">global</span> option <span class="hljs-keyword">for</span> smb.conf required arg: <span class="hljs-string">"<parameter>"</span> - IE: -g <span class="hljs-string">"log level = 2"</span> -i <span class="hljs-string">"<path>"</span> Import smbpassword required arg: <span class="hljs-string">"<path>"</span> - full file path <span class="hljs-keyword">in</span> container -n Start the <span class="hljs-string">'nmbd'</span> daemon to advertise the shares -p Set ownership <span class="hljs-keyword">and</span> permissions <span class="hljs-literal">on</span> the shares -r Disable recycle bin <span class="hljs-keyword">for</span> shares -S Disable SMB2 minimum version -s <span class="hljs-string">"<name;/path>[;browse;readonly;guest;users;admins;writelist;comment]"</span> 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 "<workgroup>" 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 '</span>command<span class="hljs-string">' (if provided and valid) will be run instead of samba </span><div class="vditor-linenumber__temp" style="display: none;"></div><span class="vditor-linenumber__rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></include></include></workgroup></workgroup></workgroup></password></username></passwd></username></username;password></path></name> Last modification:August 1, 2020 © Allow specification reprint Like 1 如果觉得我的文章对你有用,请随意赞赏