安装docker,注意是ce版的
1
2
3
4
|
┌──[root@VM-20-4-centos ~]-[~]
└─$ yum -y install docker-ce
┌──[root@VM-20-4-centos ~]-[~]
└─$ systemctl enable docker --now
|
安装gitlab镜像
1
|
docker pull beginor/gitlab-ce
|
创建对应需要的gitlab文件夹,后续做映射
1
2
3
4
|
┌──[root@VM-20-4-centos ~]-[~]
└─$ mkdir -p /data/gitlab/etc/ /data/gitlab/log /data/gitlab/data
┌──[root@VM-20-4-centos ~]-[~]
└─$ chmod 777 /data/gitlab/etc/ /data/gitlab/log /data/gitlab/data
|
启动gitlab docker
1
|
docker run -itd --name=gitlab --restart=always --privileged=true -p 8443:443 -p 80:80 -p 222:22 -v /data/gitlab/etc:/etc/gitlab -v /data/gitlab/log:/var/log/gitlab -v /data/gitlab/data:/var/opt/gitlab beginor/gitlab-ce
|
修改配置文件,添加对应的服务器ip
1
2
3
|
sed -i "/external_url 'GENERATED_EXTERNAL_URL'/a external_url\t'http://服务器IP' " /data/gitlab/etc/gitlab.rb
sed -i "/gitlab_ssh_host/a gitlab_rails['gitlab_ssh_host'] = '服务器IP' " /data/gitlab/etc/gitlab.rb
|
修改gitlab shh端口
1
|
sed -i "/gitlab_shell_ssh_port/a gitlab_rails['gitlab_shell_ssh_port'] = 222" /data/gitlab/etc/gitlab.rb
|
修改gitlab host
1
2
3
4
5
6
7
|
vim /data/gitlab/data/gitlab-rails/etc/gitlab.yml
##############################
gitlab:
## Web server settings (note: host is the FQDN, do not include http://)
host: 服务器IP
port: 80
https: false
|
报错
哇,GitLab 响应花费了太多时间
用docker logs命令去看了下容器情况,没啥问题。实际上是gitlab启动需要一些时间,如果刚启动容器就去访问的话可能会报这个错误,等个几分钟就行了
参考连接:https://blog.51cto.com/liruilong/5930717