Rui

利用Docker搭建samba服务
目前用客厅做的HTPC上运行的ubuntu,跑了aria+h5ai,但是发现回家后内网不能用samba共享文件,所...
扫描右侧二维码阅读全文
28
2019/02

利用Docker搭建samba服务

目前用客厅做的HTPC上运行的ubuntu,跑了aria+h5ai,但是发现回家后内网不能用samba共享文件,所以考虑装个sabma。但是,samba复杂的配置导致非常恶心,一旦需要重装后非常麻烦,所以就用docker实现。(不得不说以下docker真是好东西啊)

强烈不推荐直接配置samba,因为过程真的太复杂了,我至今有也没有找到合适的一键包。

抽取镜像

这个是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更新 增加官方对参数的全部解释

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
Last modification:March 2nd, 2019 at 11:02 pm

Leave a Comment