### 在docker下安装
https://docs.gitlab.cn/jh/install/docker.html
安装所需最小配置
- 内存至少4G
- 系统内核至少在3.10以上 `uname -r` 命令可查看系统内核版本
#### 安装docker
1. 更新yum源
`yum update`
2. 安装依赖
`yum install -y yum-utils device-mapper-persistent-data lvm2`
3. 添加镜像
```
//国外镜像
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
//阿里镜像
https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
```
4. 查看源中可使用版本
```
yum list docker-ce --showduplicates | sort -r
```
5. 安装指定版本
```
yum install docker
```
6. 配置开机启动项
```
systemctl start docker
systemctl enable docker
docker version
```
#### 使用容器安装gitlab
1.添加容器
```shell
docker run --detach \
--hostname 192.168.79.102 \
--publish 443:443 --publish 80:80 \
--name gitlab \
--restart always \
--volume $GITLAB_HOME/config:/etc/gitlab:Z \
--volume $GITLAB_HOME/logs:/var/log/gitlab:Z \
--volume $GITLAB_HOME/data:/var/opt/gitlab:Z \
--shm-size 256m \
registry.gitlab.cn/omnibus/gitlab-jh:latest
```
2.启动容器
```shell
docker start gitlab
```
3.查看已存在的容器
```shell
docker ps -a
```
4.进入容器
```
docker exec -it gitlab /bin/bash
```
#### 访问
http://192.168.79.102
当首次运行出现502错误的时候排查两个原因
1. 虚拟机内存至少需要4g
2. 稍微再等等刷新一下可能就好了
#### 管理员账号登录
用户名:root
密码存在下面文件中,登录后需要改密码不然24小时之后会失效
```
cat /etc/gitlab/initial_root_password
```