https://baijiahao.baidu.com/s?id=1763373699210785997&wfr=spider&for=pc

https://www.cnblogs.com/manmanblogs/p/17503351.html

git-runner

https://blog.csdn.net/qq_31518009/article/details/108092135

安装部署

https://devbox.cn/p/407283657

docker-compose  -f docker-compose  up -d


docker-compose --version

// 启动命令
docker-compose up -d

vi 删除所有行

在命令模式下,输入:.,$d 然后回车

表示从当前行到末行全部删除

gitlab官方地址:

https://about.gitlab.com/

services.gitlab.environment must be a mapping

QQ邮箱授权开启

https://blog.csdn.net/qq_41335337/article/details/117660857

四、安装Gitlab

1)编辑docker-compose的yml文件

[root@gitlab gitlab]# mkdir -p /opt/gitlab/{config,data,logs}
[root@gitlab gitlab]# ls -l /opt/gitlab/
[root@gitlab ~]# mkdir gitlab
[root@gitlab ~]# cd gitlab
[root@gitlab gitlab]# vim docker-compose.yml
[root@gitlab gitlab]# vi docker-compose.yml

正式配置文件

https://doc.rg1008.com/docs/rgacount/rgacount-1ennptln9idb0

version: '2'
services:
  gitlab:
   image: 'twang2218/gitlab-ce-zh:latest'
   container_name: "gitlab"
   restart: unless-stopped
   privileged: true
   hostname: 'gitlab'
   environment:
   TZ: 'Asia/Shanghai'
   GITLAB_OMNIBUS_CONFIG: |
    external_url 'http://ip或者用nginx做反代的域名'
    gitlab_rails['time_zone'] = 'Asia/Shanghai'
    gitlab_rails['smtp_enable'] = true
    gitlab_rails['smtp_address'] = "smtp.163.com"
    gitlab_rails['smtp_port'] = 465
    gitlab_rails['smtp_user_name'] = "xxxxxx@163.com"
    gitlab_rails['smtp_password'] = "授权码"
    gitlab_rails['smtp_domain'] = "163.com"
    gitlab_rails['smtp_authentication'] = "login"
    gitlab_rails['smtp_enable_starttls_auto'] = true
    gitlab_rails['smtp_tls'] = true
    gitlab_rails['gitlab_email_from'] = 'xxxxxx@163.com'
    gitlab_rails['gitlab_shell_ssh_port'] = 22
   ports:
    - '8181:80'
    - '8443:443'
    - '22:22'
   volumes:
    - /opt/gitlab/config:/etc/gitlab
    - /opt/gitlab/data:/var/opt/gitlab
    - /opt/gitlab/logs:/var/log/gitlab
version: '2'
services:
  gitlab:
   image: 'twang2218/gitlab-ce-zh:latest'
   container_name: "gitlab"
   restart: unless-stopped
   privileged: true
   hostname: 'gitlab'
   environment:
   TZ: 'Asia/Shanghai'
   ports:
    - '8181:80'
   volumes:
    - /opt/gitlab/config:/etc/gitlab
    - /opt/gitlab/data:/var/opt/gitlab
    - /opt/gitlab/logs:/var/log/gitlab

端口映射说明以及注意事项:

gitlab镜像官方推荐容器80端口映射宿主机8181端口
gitlab镜像官方推荐容器443端口映射宿主机8443端口
gitlab镜像官方推荐容器22端口映射宿主机22端口
⭐️头两行不能顶头写,要分别都空一行,可以去yml文件检测网站进行检测:
https://www.bejson.com/validators/yaml_editor/
如你们的检测如下图所示,则表示yml文件完全无误:

下面是在我linux服务器上看到的情况:

2)创建相关目录

?

[root@gitlab gitlab]# mkdir -p /opt/gitlab/{config,data,logs}
[root@gitlab gitlab]# ls -l /opt/gitlab/

total 0
drwxr-xr-x 2 root root 6 Dec 22 12:03 config
drwxr-xr-x 2 root root 6 Dec 22 12:03 data
drwxr-xr-x 2 root root 6 Dec 22 12:03 logs
目录说明如下:

config 存储 GitLab 配置信息
data 存储数据库
logs 存储日志
3)拉取gitlab中文版镜像

?

[root@gitlab gitlab]# docker pull twang2218/gitlab-ce-zh:latest

latest: Pulling from twang2218/gitlab-ce-zh
8ee29e426c26: Pull complete
6e83b260b73b: Pull complete
e26b65fd1143: Pull complete
40dca07f8222: Pull complete
b420ae9e10b3: Pull complete
a218309dd589: Pull complete
5c60fd7ba0ce: Pull complete
659c2144b5a3: Pull complete
8289bbac0d0e: Pull complete
31bbd150e8a7: Pull complete
9114e78243fa: Pull complete
e242e5cd1314: Pull complete
0a079dc3f92c: Pull complete
f0e195b09fd2: Pull complete
6e23346e2f58: Pull complete
91f00659be69: Pull complete
a1031bcc5b2c: Pull complete
e3074327c7b1: Pull complete
a917618dbe42: Pull complete
Digest: sha256:62686b74c6fca5ece8ed582d03a126c5988423dd8a19ce70e9a22357ffcaf1c8
Status: Downloaded newer image for twang2218/gitlab-ce-zh:latest


[root@gitlab gitlab]# docker images

REPOSITORY TAG IMAGE ID CREATED SIZE
twang2218/gitlab-ce-zh latest 18da462b5ff5 4 months ago 1.61GB
4)启动gitlab的容器

在启动前,先要修改宿主机的22端口,因为宿主机占用了22端口,所以启动容器会失败,因为映射不过来,修改如下:

vim /etc/ssh/sshd_config

默认在第17行修改:Port 2222
修改后,重启sshd:systemctl restart sshd
?

[root@gitlab gitlab]# netstat -tulnp | grep 22

tcp 0 0 0.0.0.0:2222 0.0.0.0: LISTEN 31889/sshd
tcp6 0 0 :::2222 ::: LISTEN 31889/sshd
正式启动:

?
[root@gitlab gitlab]# docker-compose up -d
Creating network “gitlab_default” with the default driver
Creating gitlab … done

[root@gitlab gitlab]# docker-compose ps

Name Command State Ports
gitlab /assets/wrapper Up (healthy) 0.0.0.0:22->22/tcp, 0.0.0.0:8443->443/tcp, 0.0.0.0:8181->80/tcp

[root@gitlab gitlab]# docker ps -
```a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
814e559dc728 twang2218/gitlab-ce-zh:latest "/assets/wrapper" 5 minutes ago Up 5 minutes (healthy) 0.0.0.0:22->22/tcp, 0.0.0.0:8181->80/tcp, 0.0.0.0:8443->443/tcp gitlab
5)gitlab设置开机启动

?
```asp
[root@gitlab gitlab]# chmod +x /etc/rc.local
[root@gitlab gitlab]# ls -l /etc/rc.local

lrwxrwxrwx 1 root root 13 Dec 3 14:31 /etc/rc.local -> rc.d/rc.local

[root@gitlab gitlab]# echo "cd /root/gitlab && docker-compose up -d" >> /etc/rc.local
[root@gitlab gitlab]# tail -1 /etc/rc.local
cd /root/gitlab && docker-compose up -d

6)gitlab管理界面
地址:在浏览器输入yml文件的第12行ip或者域名
用户:root
密码:首次登陆需要手动设置密码
如下图所示:

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

文档更新时间: 2023-08-02 21:29   作者:admin