【补充】Docker安装部署Gitlab

【补充】Docker安装部署Gitlab

【一】查询可用docker镜像

docker search gitlab
  • 查询结果如下
NAME                                     DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
bitnami/gitlab-runner                                                                    30                   
bitnami/gitlab-runner-helper                                                             3                    
alpinelinux/gitlab-runner-helper         Helper image container gitlab-runner-helper …   4                    
rapidfort/gitlab-ce                                                                      12                   
drud/gitlab-ce                                                                           18                   
okteto/gitlab                                                                            2                    
domjudge/gitlabci                                                                        0                    
alpinelinux/gitlab-runner                Alpine Linux gitlab-runner (supports more ar…   4                    
accurics/gitlab-connector                                                                0                    
wodby/gitlab                             Alpine-based GitLab CE container image          0                    
ustclug/gitlab                           Dockrized GitLab used by LUG@USTC               0                    
itisfoundation/gitlab-runner-docker                                                      0                    
alpinelinux/gitlab                       Alpine Linux based Gitlab image                 3                    
pnnlmiscscripts/gitlab-runner-operator                                                   0                    
jitesoft/gitlab-ci-runner                  Image inheriting from the gitlab runner. I…   0                    
vulhub/gitlab                                                                            0                    
alpinelinux/gitlab-shell                 Alpine Linux based gitlab-shell image, provi…   0                    
wodby/gitlab-nginx                       Nginx for GitLab CE container image             0                    
corpusops/gitlabtools                    https://github.com/corpusops/docker-gitlabto…   0                    
vulhub/gitlab-cve-2016-9086              gitlab cve-2016-9086                            0                    [OK]
drud/gitlab-backups                                                                      0                    
gromacs/gitlab-runner                                                                    0                    
wodby/gitlab-runner                                                                      0                    
osuosl/gitlab-runner-helper                                                              0                    
avenga/gitlab-job  
  • bitnami/gitlab-ce:
    • 这是一个受欢迎的GitLab CE(社区版)官方镜像,它提供了支持Docker容器化部署的完整GitLab功能。
    • 它具有30个星标和官方支持,是一个可靠的选择。
  • drud/gitlab-ce:
    • 这是另一个GitLab CE的镜像,具有18个星标。
    • 它可能提供某些特定用例的定制功能或配置。
  • rapidfort/gitlab-ce:
    • 这是一个具有12个星标的GitLab CE镜像。
    • 虽然它的星标相对较少,但它可能提供一些特定功能或配置,适合某些特殊需求。
  • 我们不安装上面搜到的,我们安装开源免费的
docker search gitlab/gitlab-ce
NAME                  DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
gitlab/gitlab-ce      GitLab Community Edition docker image based …   3958                 [OK]
gitlab/gitlab-ce-qa   GitLab QA has a test suite that allows end-t…   9  

【二】下载镜像

docker pull gitlab/gitlab-ce
  • 提示如下
Using default tag: latest
latest: Pulling from gitlab/gitlab-ce
9d19ee268e0d: Pull complete 
d2ff74cbcced: Pull complete 
d06419550771: Pull complete 
95d2910ae8cd: Pull complete 
3fe373525d3f: Pull complete 
5ac33011ebfd: Pull complete 
3e241c2fe130: Pull complete 
1e86e7e138ed: Downloading [==>                                                ]  60.52MB/1.354GB
  • 安装完成
Using default tag: latest
latest: Pulling from gitlab/gitlab-ce
9d19ee268e0d: Pull complete 
d2ff74cbcced: Pull complete 
d06419550771: Pull complete 
95d2910ae8cd: Pull complete 
3fe373525d3f: Pull complete 
5ac33011ebfd: Pull complete 
3e241c2fe130: Pull complete 
1e86e7e138ed: Pull complete 
Digest: sha256:680def18671cfb272f2ea8854043d140e165bebb340b60669eef94ec5ba37168
Status: Downloaded newer image for gitlab/gitlab-ce:latest
docker.io/gitlab/gitlab-ce:latest

【三】启动服务

docker run -d -p 10008:80 -p 10009:443 -p 10010:22 --restart always --name gitlab -v /docker/gitlab/etc/gitlab:/etc/gitlab -v /docker/gitlab/var/log/gitlab:/var/log/gitlab -v /docker/gitlab/var/opt/gitlab:/var/opt/gitlab --privileged=true gitlab/gitlab-ce

【四】修改gitlab.rb文件

vi /docker/gitlab/etc/gitlab/gitlab.rb

修改如下位置:

# 如果使用公有云且配置了域名了,可以直接设置为域名,如下
external_url 'http://gitlab.redrose2100.com'
# 如果没有域名,则直接使用宿主机的ip,如下
external_url 'http://172.22.27.162'  
# 同样如果有域名,这里也可以直接使用域名
gitlab_rails['gitlab_ssh_host'] =  'gitlab.redrosee2100.com'
# 同样如果没有域名,则直接使用宿主机的ip地址
gitlab_rails['gitlab_ssh_host'] = '172.22.27.162'
# 端口为启动docker时映射的ssh端口
gitlab_rails['gitlab_shell_ssh_port'] =10010 
# 设置时区为东八区,即北京时间
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'] = "hitredrose@163.com"   # 发件箱的邮箱地址
gitlab_rails['smtp_password'] = "xxxxxxxxxxx"      # 发件箱对应的授权码,注意不是登录密码,是授权码
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_enabled'] = true
gitlab_rails['gitlab_email_from'] = 'hitredrose@163.com'     # 发件箱地址
gitlab_rails['gitlab_email_display_name'] = 'gitlab.redrose2100.com'    # 显示名称
gitlab_rails['gitlab_email_reply_to'] = 'noreply@example.com'     # 提示不要回复

【六】重启docker

docker restart gitlab

【七】进入docker容器里

docker exec -it gitlab bash

【八】修改端口号

vi /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml

如下,将端口修改为映射后的端口

【九】重启gitlab

直接在docker中执行

gitlab-ctl restart

如:

root@cd6a79be7773:/etc/gitlab# gitlab-ctl restart
ok: run: alertmanager: (pid 4567) 1s
ok: run: gitaly: (pid 4582) 1s
ok: run: gitlab-exporter: (pid 4598) 1s
ok: run: gitlab-workhorse: (pid 4603) 1s
ok: run: grafana: (pid 4610) 1s
ok: run: logrotate: (pid 4619) 1s
ok: run: nginx: (pid 4631) 1s
ok: run: postgres-exporter: (pid 4636) 1s
ok: run: postgresql: (pid 4645) 1s
ok: run: prometheus: (pid 4653) 0s
ok: run: puma: (pid 4670) 1s
ok: run: redis: (pid 4679) 0s
ok: run: redis-exporter: (pid 4689) 1s
ok: run: sidekiq: (pid 4697) 1s
ok: run: sshd: (pid 4703) 1s
root@cd6a79be7773:/etc/gitlab

【十】在浏览器打开 ip:端口号即可访问

这里需要注意,如果使用的是阿里云,需要配置安全组放开端口,如果使用二级域名,同样需要配置Nginx代理进行解析,

【十一】查看root默认密码

cat /docker/gitlab/etc/gitlab/initial_root_password

如:

【十二】使用root用户名以及上述查询到的密码登录

【十三】登录后依次点击【头像】-【Edit profile】-【password】,然后修改密码

【十四】至此,gitlab已经安装完成,并已修改密码

posted @ 2023-08-19 17:31  Chimengmeng  阅读(316)  评论(0编辑  收藏  举报