Samba 是 SMB/CIFS 网络协议的重新实现, 它作为 NFS 的补充使得在 Linux、OS/2、DOS 和 Windows 系统中进行文件共享、打印机共享更容易实现。SMB协议是客户机/服务器型协议,客户机通过该协议可以访问服务器上的共享文件系统、打印机及其他资源。通过设置“NetBIOS over TCP/IP”使得Samba不但能与局域网络主机分享资源,还能与全世界的电脑分享资源。

这里通过使用docker镜像的方式来简化samba的安装, 来实现不同系统之间共享目录。

运行docker

sudo docker run -it -p 139:139 -p 445:445 -d dperson/samba

如果要使用本地存储,则可以:

sudo docker run -it --name samba -p 139:139 -p 445:445 \
-v /path/to/directory:/mount \
-d dperson/samba

配置参数:

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 value, 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

示例

现在要将目录xw_share, 通过139和445端口进行共享, 并创建用户xw(密码为:overkill),禁用匿名用户访问,并且允许用户xw读写操作,可以如下设置:

docker run -it --name samba -p 139:139 -p 445:445 \
-v $PWD/nl_share:/mount -d dperson/samba -u "xw;overkill" -s "xw;/mount/;yes;no;no;all;xw;xw"

参考:

  1. Samba (简体中文)
  2. samba百度百科
  3. https://github.com/dperson/samba
  4. xwxwgo

Docker镜像搭建Linux下samba共享目录的更多相关文章

  1. Docker镜像搭建ubuntu下samba目录共享

    第一种方法:(未使用) yum install docker // 下载镜像 docker pull dperson/samba // 启动镜像,具体看文档,但重要的配置是以下的注释 docker r ...

  2. windows怎么访问linux的samba共享目录

    windows怎么访问linux的samba共享目录 听语音 原创 | 浏览:6976 | 更新:2018-07-31 13:20 | 标签:LINUX WINDOWS 1 2 3 4 5 6 7 分 ...

  3. Linux下设置共享目录

    Linux系统的文件或目录的共享功能是非常强大,而且是非常灵活的,其对权限的控制可以做到非常的细致,当然如果你是通过命令行方式进行设置的 话,那么对于刚接触linux系统的用户来说将是一件十分头痛的事 ...

  4. Windows访问Linux下的共享目录的配置方法

    user安全级别 第一步:安装samba3(如果已经安装就跳过这一步)  [root@rhce2 /]# yum groupinstall "CIFS file server" 第 ...

  5. linux下nfs共享目录

    1. 关掉防火墙    systemctl disable firewalld.service 2. 关掉selinux    vim /etc/selinux/config    修改第七行:    ...

  6. virtualBox下面安装linux系统如何共享目录

    背景: 系统是win+virtualBox 在虚拟机中安装了linuxMint系统. 如何共享目录呢 第一步: 在虚拟机中安装增强功能 2,在virtualBox中设置共享目录 3,在linux下创建 ...

  7. 将samba共享目录映射为本地文件夹(百度网盘直接下载到samba共享目录下)

    将samba共享目录映射为本地文件夹(百度网盘直接下载到samba共享目录下) 前面淘了一个蜗牛星际的矿机,打算拿来做个个人云盘,就装上了Linux用smb把硬盘共享出来 访问倒是很爽,就是发现下东西 ...

  8. Linux编译Windows共享目录下代码

    Linux编译Windows共享目录下代码(金庆的专栏)万神服务器代码是跨平台的.平时策划在Windows上开自己的服务器测试,测试和发布服务器为Linux.开发时,先在Windows上编译测试,再到 ...

  9. linux下scsi共享磁盘的简单搭建

    linux下scsi共享磁盘的简单搭建 Scsi 共享磁盘需要我先有空余的分区,或者可以在虚拟机里面添加一块磁盘,安装所需的软件我在虚拟机里面添加了一块硬盘,分了一个主分区,sdb1 1G,将这个用s ...

随机推荐

  1. [日常] Go语言圣经-命令行参数

    1.编译 go build hello.go 2.go get gopl.io/ch1/helloworld 命令,就会从网上获取代码,并放到对应目录中 下载的代码会放在$GOPATH/src/gop ...

  2. java计算机二级笔记

    java.applet.AppletAppletHTMLAppletextends Appletextends AppletprintinitcalendarCalendarCalendar 日历类J ...

  3. 使用DOM解析xml文件

    使用DOM解析xml文件 要解析的xml文件如下: <?xml version="1.0" encoding="UTF-8"?> <Langu ...

  4. 将windows共享文件夹挂载在linux机器的/mnt/windows/ 目录下进行访问

    将windows共享文件夹挂载在linux机器的/mnt/windows/ 目录下进行访问.windows机器ip:192.168.1.101,用户名:XXXX密码:XXXXlinux机器ip:ip2 ...

  5. 使用 Vuejs 开发 chrome 插件的注意事项

    使用 Vuejs 开发 chrome 插件 chrome 插件的开发其实并不难,web开发者可以使用 html, css, javascript 轻松的开发实用的 chrome 插件. 一个好的 ch ...

  6. vue三要素及底层实现机制

    深入解析Vue 我们首先来熟悉一下我们这个文档所学习内容的流程. 先对比一下jQuery和Vue的区别,再讲述Vue的MVVM模型,接着讲解Vue的实现流程. 当然,我是不相信没有对比哪来的伤害,没有 ...

  7. Modernizing Business Process with Cloud and AI

    The world is awash with digital transformation. Every customer and partner that I talk to, across ev ...

  8. CRM 安装过程 AD+SQL+CRM

    AD: 通过服务器管理器添加域服务,配置域服务器域名为crm5.lab. 注意:使用高级模式安装. 说明:服务器是windows server 2003 那么就选windows server 2003 ...

  9. angularjs -- 监听angularJs列表数据是否渲染完毕

    前端在做数据渲染的时候经常会遇到在数据渲染完毕后执行某些操作,这几天就一直遇到在列表和表格渲染完毕后,执行点击和选择操作.对于angularjs处理这类问题,最好的方式就是指令 directive. ...

  10. 聊聊 getClientRects 和 getBoundingClientRect 方法

    开始表演 今天来聊一下两个相似的方法,它们就是:getBoundingClientRect().getClientRects(). 只见它们俩手拉手地登上了舞台,一个鞠躬,便开始滔滔不绝起来. 自述 ...