Docker 搭建·svn服务

启动centos 基础镜像

[root@jhkj69 home]# docker run -i -t  centos:7.2.1511 /bin/bash

安装svn

[root@0f5af74842ec /]# yum install -y subversion

验证是否成功:

[root@0f5af74842ec home]# svnserve –version

创建svn版本库:

[root@0f5af74842ec home]# mkdir svn

[root@0f5af74842ec home]# svnadmin create /home/svn/repo1

[root@0f5af74842ec home]# ll svn/repo1/

total 16

-rw-r--r--. 1 root root  229 Oct 10 06:36 README.txt

drwxr-xr-x. 2 root root   51 Oct 10 06:36 conf

drwxr-sr-x. 6 root root 4096 Oct 10 06:36 db

-r--r--r--. 1 root root    2 Oct 10 06:36 format

drwxr-xr-x. 2 root root 4096 Oct 10 06:36 hooks

drwxr-xr-x. 2 root root   39 Oct 10 06:36 locks

说明:

1、        svnserve.conf :svn服务综合配置文件

2、        passwd:用户名口令文件,前边是svn账号,后边是密码,密码是明文存储,配置哪些用户可以授权使用,里面包含用户名和密码

3、        authz:权限配置文件

4、        注意修改svnserve.conf配置文件需要重启svn,修改authz和passwd则不用重启svn,重启svn方式为:pkill svnserve 然后重新svnserve -d -r

修改passwd文件:

vi passwd

[users]

# harry = harryssecret

# sally = sallyssecret

jianng = 123456

修改authz文件:

[aliases]

# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average

 

[groups]

# harry_and_sally = harry,sally

# harry_sally_and_joe = harry,sally,&joe

team1 = jiang

 

# [/foo/bar]

# harry = rw

# &joe = r

# * =

 

# [repository:/baz/fuz]

# @harry_and_sally = rw

# * = r

[repo1:/]

@team1 = rw

修改svnserve.conf并重启svn:

anon-access = none

auth-access = write

password-db = passwd 统一制定一个passwd文件便于管理不需要单独每个版本库单独配置

authz-db = authz

[root@0f5af74842ec conf]# pkill svnserve

[root@0f5af74842ec conf]# svnserve -d -r /home/svn/repo1/

提交新镜像:

[root@jhkj69 home]# docker commit 0581780fec1a svn:v1.0

[root@jhkj69 home]# docker images

REPOSITORY                        TAG                 IMAGE ID            CREATED             SIZE

svn                               v1.0                9b63a3442392        27 seconds ago      366MB