用Docker安装Gitlab,搭建免费的私有代码托管平台
2018-04-09 本文已影响53人
褪色的记忆1994
相信做IT这行的一般都使用过github,我们可以在上面找到许多现成的代码,当然我们也可以在上面发布我们的代码。但github只提供免费的公共项目,私有项目是需要付费的。下面我将在docker的基础上搭建一个自己的私有代码托管平台。
- 安装docker环境
我是用的是ubuntu平台,其他平台大同小异,可参考官网https://www.docker.com/
$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh
这是安装docker环境较为简单的一种方法。
检查是否安装成功
$ sudo docker version
Client:
Version: 17.03.1-ce
API version: 1.27
Go version: go1.7.5
Git commit: c6d412e
Built: Mon Mar 27 17:14:09 2017
OS/Arch: linux/amd64
Server:
Version: 17.03.1-ce
API version: 1.27 (minimum version 1.12)
Go version: go1.7.5
Git commit: c6d412e
Built: Mon Mar 27 17:14:09 2017
OS/Arch: linux/amd64
Experimental: false
当我们运行sudo docker version
看到如上Client与Server都启动时,证明已安装成功。
- 拉取Gitlab镜像
$ sudo docker pull gitlab/gitlab-ce:latest
latest: Pulling from gitlab/gitlab-ce
9fb6c798fa41: Already exists
3b61febd4aef: Already exists
9d99b9777eb0: Already exists
d010c8cf75d7: Already exists
7fac07fb303e: Already exists
ae2fdb575b06: Pull complete
e17254fcdaa5: Pull complete
51ee0e488e7a: Pull complete
0e358475ab4c: Pull complete
097988c3d66c: Pull complete
70a83b240617: Pull complete
Digest: sha256:ced2a98b77d3ad420c125111ea5d90c084b33c8486b14e20ca3c610f2010dda4
Status: Downloaded newer image for gitlab/gitlab-ce:latest
如果镜像速度慢的话可以选择国内阿里云或者其他服务商提供的镜像,或者使用DaoCloud提供的免费镜像加速器,具体教程看:http://www.daocloud.io/mirror
- 根据自己的需求运行镜像
sudo docker run --detach \
--hostname localhost \
--publish 444:443 --publish 8880:80 --publish 2222:22 \
--name gitlab \
--restart always \
gitlab/gitlab-ce:latest
hostname表示访问的host地址,我这里把三个端口的映射端口都进行了修改,避免与其他已有服务冲突。
- 进入gitlab容器内部修改相关设置
因为修改了hostname已经映射的端口,直接运行后并不能直接访问,需要进入容器后修改相关设置。docker版gitlab提供了一个同一配置修改文件,几乎所有的配置都在这里修改。
个人博客:https://blog.xvjialing.xyz
github主页:https://github.com/xvjialing
微信公众号
![](https://img.haomeiwen.com/i3804491/1136ea5d14d234a9.jpg)