使用docker搭建gitlab版本控制系统

1. GitLab 简介 GitLab 是一款基于 git 的开源代码仓库系统 
 GitLab 与著名的 GitHub 最大的区别就是:  允许我们搭建自己的 git 代码私有仓库,非常方便
 
2、安装Gitlab  
安装Gitlab特别的复杂,因此这里我们使用docker搭建一款Gitlab,特别方便
(1)在Centos7上面安装docker
 
 
  1. #yum -y install docker 
  2. #systemctl restart  docker
 
(2)从官方的hub里面拉取gitlab镜像
  1. docker pull gitlab/gitlab-ce
查看镜像
 
  1. docker images
 
REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
docker.io/gitlab/gitlab-ce   latest              4635a2b4fefc        21 hours ago        1.401 GB
(3)从gitlab镜像启动容器
 
  1. docker run -d -h gitlab -p 443:443-p 80:80  -p 2222:22--name gitlab --restart always  -v /root/data/gitlab/config:/etc/gitlab -v /root/data/gitlab/logs:/var/log/gitlab \
  2. -v  /root/data/gitlab/data:/var/opt/gitlab  docker.io/gitlab/gitlab-ce
 
 
说明:
-d 后台启动
-h  hostname
-p 容器的端口映射
--name 容器的名字
 --restart always  当容器退出或宿主机重启的时候,容器接着会始终重启
-v  给容器添加一个数据卷
 
(4)修改gitlab容器的配置文件
  1. docker exec -it gitlab vi /etc/gitlab/gitlab.rb
 
修改为服务器的ip地址:
  1. 13 external_url 'http://115.159.84.173'
 
然后重启容器gitlab
  1. docker restart  gitlab
 
(5)访问gitab  http://115.159.84.173
 
 
登录之后新建工程
 
 
 

 
 
 
 
 
这里测试,服务器IP变成 192.168.200.128
 
在另外的Linux服务器上操作:
 
 
  1. # git config --global user.name "shiyong"
  2. # git config --global user.email "shiyong@qq.com"
 
 
 
 
  1. # git clone http://192.168.200.128/shiyong/abc.git
 
正克隆到 'abc'...
Username for 'http://192.168.200.128': shiyong     
Password for 'http://shiyong@192.168.200.128': 
warning: 您似乎克隆了一个空版本库。
 
 
  1. [root@localhost abc]# ls abc/
 
 
 
  1. cd abc
  2. # touch README.md
  3. vi README.md 
  4.  README.md
  5. git commit -m "add README"
 
gitlab属于分布式版本控制系统,可以在别的服务器上,就行git clone操作
 
  1. git clone http://192.168.200.128/shiyong/abc.git
 
正克隆到 'abc'...
 
 
 
 
原文地址:https://www.cnblogs.com/gdlinux/p/6760919.html