1. Use the docker command to download the svn image
//Search for svn mirror docker search svn //Download the first image: docker.io/garethflowers/svn-server docker pull docker.io/garethflowers/svn-server
The operation diagram is as follows:
2. Run the svn container and configure host mapping
2.1. First create a dev/svn/repo directory under the /usr/local directory, and map the svn container warehouse directory in docker to /usr/local/dev/svn/repo on the host.
I have created the directory as follows:
2.2. Use the docker command to map the directory and start the svn container
//docker runs svn command docker run --restart always --name svn -d -v /usr/local/dev/svn/repo:/var/opt/svn -p 3690:3690 garethflowers/svn-server Brief analysis
- /root/dockers/svn is the file directory of the host, and /var/opt/svn is the file directory of the container.
- The --restart always command can enable the container to start automatically when the host is turned on.
- -p 3690:3690 means mapping the 3690 port of the host to the 3690 port of the container. This port is the default port of the svn service and can be modified as needed.
Success is as follows:
3. Enter the svn container, create an account and configuration
//Enter the svn container docker exec -it svn /bin/sh
3.2 Create a resource warehouse named svn
svnadmin create svn //The above code creates an svn warehouse directory, and there will be several files in it: README.txt conf db format hooks locks Success is as shown below
Modify the file configuration in the svn directory, command: vi svnserve.conf
The file configuration content is as follows: anon-access = none # Anonymous users cannot read or write, and can also be set to read-only. auth-access = write # Authorized users can write password-db = passwd # Password file path, relative to the current directory authz-db = authz #Access control file realm = /var/opt/svn/svn # Authentication namespace, which will be displayed on the authentication prompt interface and used as a keyword for credential cache. You can write the warehouse name such as svn (The Chinese comments in my comments are not displayed here. It should be a docker configuration encoding problem. I was too lazy to configure it, so I didn’t write the Chinese comments)
The operation diagram is as follows:
Modify the passwd, and authz files. Without these two files, directly create and modify: vi passwd and vi authz
The contents of the passwd file are as follows: [users] # harry = harryssecret # sally = sallyssecret admin = 123456 The contents of the authz file are as follows: [groups] owner = admin [/] # / represents all warehouses admin = rw # User admin has read and write permissions in all warehouses [svn:/] # Indicates that the following users have corresponding permissions in all directories of the warehouse svn @owner = rw # Indicates that users under the owner group have read and write permissions
The content of the operation diagram is as follows:
4. Copy the resource library repository generated in the container to the corresponding directory of the host. Because this information will be lost once the container is restarted, it should be persisted to the file system of the host.
#Reference command: docker cp container ID:/var/opt/svn/repository/ /opt/data/svn/repo //My real path command copy
docker cp 4245e47be88e:/var/opt/svn/svn/ /usr/local/dev/svn/repo
//Restart svn container or command:
docker restart container ID or
docker restart svn
4. Exit the container: exit, and then copy the resource library repository generated in the container to the corresponding directory of the host. Because this information will be lost once the container is restarted, it should be persisted to the file system of the host.
docker cp 容器ID:/var/opt/svn/repository/ /opt/data/svn/repo //Restart the svn container again docker restart svn or docker restart container ID
5. Use the command to see if it is successful:
svn co svn://127.0.0.1:3690/svn