【实战Docker】SVN服务
2019.06.05
----------------------------------------------------------------------------------
docker pull harbor.ratp.com/library/garethflowers/svn-server:1.2.2
----------------------------------------------------------------------------------
datadev@data-dev ~/xxxx/docker2019/docker-fileserv/svn-server$ docker pull harbor.ratp.com/library/garethflowers/svn-server:1.2.2
WARNING: Error loading config file:/home/datadev/.docker/config.json - stat /home/datadev/.docker/config.json: permission denied
1.2.2: Pulling from library/garethflowers/svn-server
bdf0201b3a05: Pull complete
4bae6ca1e4a0: Pull complete
c13ab2789d28: Pull complete
Digest: sha256:62cdd515b2bbdbd9f8ff2a0d0e3e1294cfdf80b2b39606ee3475e7210b1daf30
Status: Downloaded newer image for harbor.ratp.com/library/garethflowers/svn-server:1.2.2
datadev@data-dev ~/xxxx/docker2019/docker-fileserv/svn-server$
----------------------------------------------------------------------------------
datadev@data-dev ~/xxxx/docker2019/docker-fileserv/svn-server$ sudo mkdir -p /data/svn-repo
----------------------------------------------------------------------------------
sudo docker run -d --name svn-serv \
-p 3690:3690 \
-v /data/svn-repo:/var/opt/svn \
harbor.ratp.com/library/garethflowers/svn-server:1.2.2
----------------------------------------------------------------------------------
datadev@data-dev ~/xxxx/docker2019/docker-fileserv/svn-server$ ./run-svn.sh
[sudo] password for datadev:
Sorry, try again.
[sudo] password for datadev:
c7c62732ebbbbf20be5e70ba96d1fe74a9e88890b3b20d2f4240c12fbf25143e
datadev@data-dev ~/xxxx/docker2019/docker-fileserv/svn-server$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c7c62732ebbb harbor.ratp.com/library/garethflowers/svn-server:1.2.2 "/usr/bin/svnserve..." 5 seconds ago Up 4 seconds (health: starting) 0.0.0.0:3690->3690/tcp svn-serv
118c30803549 dperson/samba:20180228 "samba.sh samba.sh..." 17 hours ago Up 17 hours (healthy) 0.0.0.0:139->139/tcp, 137-138/udp, 0.0.0.0:445->445/tcp samba
----------------------------------------------------------------------------------
datadev@data-dev ~/xxxx/docker2019/docker-fileserv/svn-server$ sudo docker exec -it svn-serv /bin/sh
/var/opt/svn # env
HOSTNAME=c7c62732ebbb
SHLVL=1
HOME=/root
TERM=xterm
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/var/opt/svn
/var/opt/svn # ls
/var/opt/svn #
/var/opt/svn # which svnadmin
/usr/bin/svnadmin
/var/opt/svn # svnadmin --help
general usage: svnadmin SUBCOMMAND REPOS_PATH [ARGS & OPTIONS ...]
Subversion repository administration tool.
Type 'svnadmin help <subcommand>' for help on a specific subcommand.
Type 'svnadmin --version' to see the program version and FS modules.
Available subcommands:
crashtest
create
delrevprop
deltify
dump
dump-revprops
freeze
help (?, h)
hotcopy
info
list-dblogs
list-unused-dblogs
load
load-revprops
lock
lslocks
lstxns
pack
recover
rmlocks
rmtxns
setlog
setrevprop
setuuid
unlock
upgrade
verify
/var/opt/svn #
/var/opt/svn # svnadmin --version
svnadmin, version 1.11.1 (r1850623)
compiled Jan 28 2019, 16:16:33 on x86_64-alpine-linux-musl
Copyright (C) 2019 The Apache Software Foundation.
This software consists of contributions made by many people;
see the NOTICE file for more information.
Subversion is open source software, see http://subversion.apache.org/
The following repository back-end (FS) modules are available:
* fs_fs : Module for working with a plain file (FSFS) repository.
* fs_x : Module for working with an experimental (FSX) repository.
* fs_base : Module for working with a Berkeley DB repository.
/var/opt/svn #
/var/opt/svn # svnadmin help create
create: usage: svnadmin create REPOS_PATH
Create a new, empty repository at REPOS_PATH.
Valid options:
--bdb-txn-nosync : disable fsync at transaction commit [Berkeley DB]
--bdb-log-keep : disable automatic log file removal [Berkeley DB]
--config-dir ARG : read user configuration files from directory ARG
--fs-type ARG : type of repository:
'fsfs' (default), 'bdb' or 'fsx'
CAUTION: FSX is for EXPERIMENTAL use only!
--compatible-version ARG : use repository format compatible with Subversion
version ARG ("1.5.5", "1.7", etc.)
--pre-1.4-compatible : deprecated; see --compatible-version
--pre-1.5-compatible : deprecated; see --compatible-version
--pre-1.6-compatible : deprecated; see --compatible-version
/var/opt/svn #
/var/opt/svn # ps ax
PID USER TIME COMMAND
1 root 0:00 /usr/bin/svnserve --daemon --foreground --root /var/opt/svn
35 root 0:00 /bin/sh
209 root 0:00 ps ax
/var/opt/svn #
----------------------------------------------------------------------------------
/var/opt/svn # svnadmin create SATP文档库
/var/opt/svn # ls
SATP文档库
/var/opt/svn #
----------------------------------------------------------------------------------
datadev@data-dev ~/xxxx/docker2019/docker-fileserv/svn-server$ ls /data/svn-repo/
SATP文档库
datadev@data-dev ~/xxxx/docker2019/docker-fileserv/svn-server$ ls /data/svn-repo/SATP文档库/ -la
total 32
drwxr-xr-x 6 root root 4096 Jun 5 15:10 .
drwxr-xr-x 3 root root 4096 Jun 5 15:10 ..
drwxr-xr-x 2 root root 4096 Jun 5 15:10 conf
drwxr-sr-x 6 root root 4096 Jun 5 15:10 db
-r--r--r-- 1 root root 2 Jun 5 15:10 format
drwxr-xr-x 2 root root 4096 Jun 5 15:10 hooks
drwxr-xr-x 2 root root 4096 Jun 5 15:10 locks
-rw-r--r-- 1 root root 246 Jun 5 15:10 README.txt
datadev@data-dev ~/xxxx/docker2019/docker-fileserv/svn-server$
----------------------------------------------------------------------------------
/var/opt/svn # svnadmin create test
/var/opt/svn # ls
SATP文档库 test
/var/opt/svn #
----------------------------------------------------------------------------------
use TortoiseSVN to access: svn://10.17.22.210:3690/SATP文档库
svn://10.17.22.210/SATP文档库
----------------------------------------------------------------------------------
Add users and set the password:
----------------------------------------------------------------------------------
/var/opt/svn/SATP文档库 # cd conf/
/var/opt/svn/SATP文档库/conf # ls
authz hooks-env.tmpl passwd svnserve.conf
/var/opt/svn/SATP文档库/conf # ls -l
total 20
-rw-r--r-- 1 root root 1080 Jun 5 07:10 authz
-rw-r--r-- 1 root root 885 Jun 5 07:10 hooks-env.tmpl
-rw-r--r-- 1 root root 309 Jun 5 07:10 passwd
-rw-r--r-- 1 root root 4375 Jun 5 07:10 svnserve.conf
/var/opt/svn/SATP文档库/conf #
----------------------------------------------------------------------------------
/var/opt/svn/SATP文档库/conf # cat authz
### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to:
### - a single user,
### - a group of users defined in a special [groups] section,
### - an alias defined in a special [aliases] section,
### - all authenticated users, using the '$authenticated' token,
### - only anonymous users, using the '$anonymous' token,
### - anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rule with '~'. Rules can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').
[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
# [/foo/bar]
# harry = rw
# &joe = r
# * =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
/var/opt/svn/SATP文档库/conf # cat passwd
### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.
[users]
# harry = harryssecret
# sally = sallyssecret
/var/opt/svn/SATP文档库/conf # cat svnserve.conf
### This file controls the configuration of the svnserve daemon, if you
### use it to allow access to this repository. (If you only allow
### access through http: and/or file: URLs, then this file is
### irrelevant.)
### Visit http://subversion.apache.org/ for more information.
[general]
### The anon-access and auth-access options control access to the
### repository for unauthenticated (a.k.a. anonymous) users and
### authenticated users, respectively.
### Valid values are "write", "read", and "none".
### Setting the value to "none" prohibits both reading and writing;
### "read" allows read-only access, and "write" allows complete
### read/write access to the repository.
### The sample settings below are the defaults and specify that anonymous
### users have read-only access to the repository, while authenticated
### users have read and write access to the repository.
# anon-access = read
# auth-access = write
### The password-db option controls the location of the password
### database file. Unless you specify a path starting with a /,
### the file's location is relative to the directory containing
### this configuration file.
### If SASL is enabled (see below), this file will NOT be used.
### Uncomment the line below to use the default password file.
# password-db = passwd
### The authz-db option controls the location of the authorization
### rules for path-based access control. Unless you specify a path
### starting with a /, the file's location is relative to the
### directory containing this file. The specified path may be a
### repository relative URL (^/) or an absolute file:// URL to a text
### file in a Subversion repository. If you don't specify an authz-db,
### no path-based access control is done.
### Uncomment the line below to use the default authorization file.
# authz-db = authz
### The groups-db option controls the location of the file with the
### group definitions and allows maintaining groups separately from the
### authorization rules. The groups-db file is of the same format as the
### authz-db file and should contain a single [groups] section with the
### group definitions. If the option is enabled, the authz-db file cannot
### contain a [groups] section. Unless you specify a path starting with
### a /, the file's location is relative to the directory containing this
### file. The specified path may be a repository relative URL (^/) or an
### absolute file:// URL to a text file in a Subversion repository.
### This option is not being used by default.
# groups-db = groups
### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa. The default realm
### is repository's uuid.
# realm = My First Repository
### The force-username-case option causes svnserve to case-normalize
### usernames before comparing them against the authorization rules in the
### authz-db file configured above. Valid values are "upper" (to upper-
### case the usernames), "lower" (to lowercase the usernames), and
### "none" (to compare usernames as-is without case conversion, which
### is the default behavior).
# force-username-case = none
### The hooks-env options specifies a path to the hook script environment
### configuration file. This option overrides the per-repository default
### and can be used to configure the hook script environment for multiple
### repositories in a single file, if an absolute path is specified.
### Unless you specify an absolute path, the file's location is relative
### to the directory containing this file.
# hooks-env = hooks-env
[sasl]
### This option specifies whether you want to use the Cyrus SASL
### library for authentication. Default is false.
### Enabling this option requires svnserve to have been built with Cyrus
### SASL support; to check, run 'svnserve --version' and look for a line
### reading 'Cyrus SASL authentication is available.'
# use-sasl = true
### These options specify the desired strength of the security layer
### that you want SASL to provide. 0 means no encryption, 1 means
### integrity-checking only, values larger than 1 are correlated
### to the effective key length for encryption (e.g. 128 means 128-bit
### encryption). The values below are the defaults.
# min-encryption = 0
# max-encryption = 256
/var/opt/svn/SATP文档库/conf #
----------------------------------------------------------------------------------
/var/opt/svn/SATP文档库/conf # vi 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
team_satp = hehg,panb,zhangyt,ruanll,huangchg,lulq,linx
# [/foo/bar]
# harry = rw
# &joe = r
# * =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
[\]
@team-satp = rw
----------------------------------------------------------------------------------
/var/opt/svn/SATP文档库/conf # vi passwd
/var/opt/svn/SATP文档库/conf # cat passwd
### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.
[users]
# harry = harryssecret
# sally = sallyssecret
heh = heh
panbb = panbb
zhangyy = zhangyy
ruanll = ruanll
huangch = huangch
lul = lul
lin = lin
/var/opt/svn/SATP文档库/conf #
heh = he.hai
panbb = pan.beib
zhangyy = zhang.youy
ruanll = ruan.lingling
huangch = huang.chu
lul = lu.lie
lin = li.ning
----------------------------------------------------------------------------------
/var/opt/svn/SATP文档库/conf # vi svnserve.conf
# anon-access = read
# auth-access = write
auth-access = write
# password-db = passwd
password-db = passwd
# realm = My First Repository
realm = 10.17.191.210
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
datadev@data-dev ~/xxxx/docker2019/docker-fileserv/svn-server$ cat docker-compose_svnserver.yml
version: '2.1'
services:
svnserver:
image: harbor.ratp.com/library/garethflowers/svn-server:1.2.2
hostname: svnserver
container_name: svnserver
restart: always
ports:
- 3690:3690
volumes:
- /data/svn-repo:/var/opt/svn
#- /etc/passwd:/etc/passwd:ro
#- /etc/group:/etc/group:ro
- /etc/timezone:/etc/TZ:ro
- /etc/localtime:/etc/localtime:ro
#Creating a new SVN Repository
#Use svnadmin within your container to create and manage repositories.
#For example, to create a repository called new-repo in container svnserver, use the following:
#docker exec -it svnserver svnadmin create new-repo
datadev@data-dev ~/xxxx/docker2019/docker-fileserv/svn-server$
datadev@data-dev ~/xxxx/docker2019/docker-fileserv/svn-server$ cat svnserv-up.sh
#!/bin/bash
#
# svnserver up script
#
sudo docker-compose -f docker-compose_svnserver.yml up -d
exit
datadev@data-dev ~/xxxx/docker2019/docker-fileserv/svn-server$ cat svnserv-down.sh
#!/bin/bash
#
# svnserver down script
#
sudo docker-compose -f docker-compose_svnserver.yml down
exit
datadev@data-dev ~/xxxx/docker2019/docker-fileserv/svn-server$
----------------------------------------------------------------------------------
$ ./svnserv-up.sh
[sudo] password for datadev:
WARNING: The Docker Engine you're using is running in swarm mode.
Compose does not use swarm mode to deploy services to multiple nodes in a swarm. All containers will be scheduled on the current node.
To deploy your application across the swarm, use `docker stack deploy`.
Creating network "svnserver_default" with the default driver
Creating svnserver ...
Creating svnserver ... done
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
hub.docker.com
----------------------------------------------------------------------------------
https://hub.docker.com/r/garethflowers/svn-server
garethflowers/svn-server
By garethflowers • Updated a month ago
A simple Subversion (SVN) server, using `svnserve`.
docker pull garethflowers/svn-server:1.2.2
SVN Server
A simple Subversion server, using svnserve.
How to use this image
Start a Subversion Server instance
To start a container, with data stored in /home/svn on the host, use the following:
docker run \
--name my-svn-server \
--detach \
--volume /home/svn:/var/opt/svn \
--publish 3690:3690 \
garethflowers/svn-server
Creating a new SVN Repository
Use svnadmin within your container to create and manage repositories.
For example, to create a repository called new-repo in container my-svn-server, use the following:
docker exec -it my-svn-server svnadmin create new-repo
License
Apache Subversion is released under the Apache License.
This image is released under the MIT License.
Tags (13)
master 6 MB
Last update: a month ago (May 3, 2019 12:35 AM)
latest 6 MB
Last update: a month ago (May 3, 2019 12:35 AM)
1.2.2 6 MB
Last update: a month ago (May 3, 2019 12:35 AM)
Dockerfile
FROM alpine:3.9
ARG BUILD_DATE
ARG VCS_REF
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.docker.cmd="docker run --detach --publish 3690:3690 --volume $PWD:/var/opt/svn garethflowers/svn-server" \
org.label-schema.description="SVN Server" \
org.label-schema.name="svn-server" \
org.label-schema.schema-version="1.0" \
org.label-schema.url="https://subversion.apache.org" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/garethflowers/docker-svn-server" \
org.label-schema.vendor="garethflowers" \
org.label-schema.version="1.2.2"
CMD [ "/usr/bin/svnserve", "--daemon", "--foreground", "--root", "/var/opt/svn" ]
EXPOSE 3690
HEALTHCHECK CMD netstat -ln | grep 3690 || exit 1
VOLUME [ "/var/opt/svn" ]
WORKDIR /var/opt/svn
RUN apk add --no-cache subversion==1.11.1-r0
----------------------------------------------------------------------------------