赞
踩
1.拉取samba镜像:docker pull dperson/samba
2.升级docker-compose版本:
通过docker-compose --version
查看版本:
[root@test samba]# docker-compose --version
docker-compose version 1.16.1, build 6d1ac21
进行升级:
[root@test samba]# curl -L https://github.com/docker/compose/releases/download/1.27.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:06 --:--:-- 0
100 11.6M 100 11.6M 0 0 109k 0 0:01:48 0:01:48 --:--:-- 104k
[root@test samba]# chmod +x /usr/local/bin/docker-compose
[root@test samba]# docker-compose --version
docker-compose version 1.27.2, build 18f557f9
至此基础环境准备完成。
文件内容如下:
[root@test samba]# cat docker-compose.yaml version: '2' services: samba: image: 'dperson/samba:latest' restart: unless-stopped ports: - "137:137/udp" - "138:138/udp" - '139:139/tcp' - '445:445/tcp' volumes: - ./mount:/mount - /data:/data - /home/app/:/app environment: TZ: Asia/Shanghai command: - '-n' - '-p' - '-r' - '-u' - "root;123456" - "-s" - "public;/mount;;;;;;;文件访问目录" - "-s" - "scm;/mount;yes;no;no;root;;;文件管理目录" - "-s" - "backup;/data/backup;yes;no;no;root;root;root;备份文件目录" - "-s" - "share;/app/share;yes;no;yes;;;;共享文件目录" networks: default: external: name: app_bus
samba服务权限设置:
创建docker网络:
[root@test samba]# docker network create app_bus
7416dbc767204694b3a62db57358f52f6e53fc0e4c42ba3dfd8075cb51ca3ea5
创建容器:
[root@test samba]# docker-compose up -d
Creating samba_samba_1 ... done
查看容器状态:
[root@test mount]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4809686c1a5b dperson/samba:latest "/sbin/tini -- /usr/…" 10 minutes ago Up 10 minutes (healthy) 0.0.0.0:139->139/tcp, :::139->139/tcp, 0.0.0.0:137-138->137-138/udp, :::137-138->137-138/udp, 0.0.0.0:445->445/tcp, :::445->445/tcp samba_samba_1
本地进行访问测试:
进入文件夹并登陆,账号密码为yaml文件中自己设置的账号密码:
如图所示,可进行正常登录:
查看各挂载目录:
[root@test samba]# ls docker-compose.yaml mount [root@test samba]# pwd /home/app/samba [root@test share]# pwd /home/app/share [root@test data]# ls backup image_back [root@test data]# ll total 0 drwxrwxr-x 2 100 101 6 Oct 24 23:46 backup drwxr-xr-x 2 root root 67 Oct 24 23:38 image_back [root@test data]# pwd /data
创建测试文件,查看是否能在samba服务中访问:
[root@test data]# cd backup/
[root@test backup]# ls
[root@test backup]# touch test.txt
[root@test backup]# ls
test.txt
至此,samba服务已部署成功。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。