Centos7:Docker安装Gitlab

官方教程 
https://docs.gitlab.com/omnibus/docker/

[root@master ~]# docker search gitlab 
INDEX       NAME                                                   DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/gitlab/gitlab-ce                             GitLab Community Edition docker image base...   1784                 [OK]
docker.io   docker.io/sameersbn/gitlab                             Dockerized gitlab web server                    1022                 [OK]
docker.io   docker.io/gitlab/gitlab-runner                         GitLab CI Multi Runner used to fetch and r...   311                  [OK]
docker.io   docker.io/twang2218/gitlab-ce-zh                       汉化的 GitLab 社区版 Docker Image                     99                   [OK]
docker.io   docker.io/gitlab/gitlab-ee                             GitLab Enterprise Edition docker image bas...   89                   
docker.io   docker.io/jangrewe/gitlab-ci-android                   GitLab CI image for building Android apps       36                   [OK]
docker.io   docker.io/centurylink/gitlab                           This image uses the image from sameersbn /...   24                   [OK]
docker.io   docker.io/gitlab/dind                                                                                  21                   [OK]
docker.io   docker.io/cdrx/rancher-gitlab-deploy                   Painless deployment of projects built with...   19                   [OK]
docker.io   docker.io/edbizarro/gitlab-ci-pipeline-php             Build and test PHP applications with Gitla...   9                    
docker.io   docker.io/klud/gitlab-runner                           GitLab Runner for ARM devices                   8                    
docker.io   docker.io/ciricihq/gitlab-sonar-scanner                Gitlab Docker container to run sonar-scann...   5                    [OK]
docker.io   docker.io/gitlab/gitlab-runner-helper                                                                  5                    
docker.io   docker.io/gitlab/cog                                   GitLab Bundle for Cog                           3                    
docker.io   docker.io/dockerphp/gitlab-ci-pipeline                 Gitlab CI pipeline for PHP applications         2                    [OK]
docker.io   docker.io/adamkl/gitlab-merge-request-resource         Customized with support for gitlab ssh on ...   1                    [OK]
docker.io   docker.io/benyoo/gitlab                                基于sameersbn/gitlab:8.9.4和GitLab 中䬮.           1                    [OK]
docker.io   docker.io/gotfix/gitlab                                Dockerized Gitlab with a lot of configurab...   1                    
docker.io   docker.io/mastertinner/gitlab-merge-request-resource   A concourse resource to check for new merg...   1                    [OK]
docker.io   docker.io/primetoninc/gitlab                           gitlab-ce                                       1                    [OK]
docker.io   docker.io/sgillespie/gitlab-runner                     A Dockerized GitLab Runner that automatica...   1                    [OK]
docker.io   docker.io/gitlab/gitlab-qa                             GitLab QA has a test suite that allows end...   0                    
docker.io   docker.io/instrumentisto/gitlab-builder                Docker image with minimal toolchain requir...   0                    [OK]
docker.io   docker.io/sicony/npm-cache-gitlab-mr                   Concourse CI npm cache resource for gitlab...   0                    
docker.io   docker.io/stanfordlegion/gitlab-ci                     An image for Gitlab CI.                         0                    [OK]
[root@master ~]#

 

[root@master ~]# docker pull docker.io/gitlab/gitlab-ce
Using default tag: latest
Trying to pull repository docker.io/gitlab/gitlab-ce ... 
latest: Pulling from docker.io/gitlab/gitlab-ce
22dc81ace0ea: Pull complete 
1a8b3c87dba3: Pull complete 
91390a1c435a: Pull complete 
07844b14977e: Pull complete 
b78396653dae: Pull complete 
b7b27b5a862c: Pull complete 
b36426107b6c: Pull complete 
3368a63e7ee5: Pull complete 
9af48542e108: Pull complete 
89277d2aced7: Pull complete 
023bfed27041: Pull complete 
Digest: sha256:194d10fcb9421517ce739fb837d8b015bb9154969466e62b0ab057264f063f58
[root@master ~]# 

在服务器上创建目录

[root@master ~]# mkdir -p /docker/gitlab/config
[root@master ~]# mkdir -p /docker/gitlab/logs
[root@master ~]# mkdir -p /docker/gitlab/data
docker run  
   -d \
   -h gitlab \
   -p 2222:22 \
   -p 8888:80 \
   -p 8443:443 \
   -v /docker/gitlab/config:/etc/gitlab \
   -v /docker/gitlab/logs:/var/log/gitlab \
   -v /docker/gitlab/data:/var/opt/gitlab \
   --restart always \
   --name gitlab \
   gitlab/gitlab-ce:latest

参数说明:

--detach: 设置容器后台运行
--hostname: 设置容器的 hostname
--publish: 端口转发规则(80:Http 访问端口,443:Https 访问端口,8888:主机的 ssh 访问端口,22:Docker 容器中 ssh 访问端口)
--name:容器名称
--restart always:每次启动容器就重启GitLab
--volume: 共享目录挂载,即 docker 容器内外数据共享(/srv/gitlab/data: 应用程序数据,/srv/gitlab/logs:GitLab 的 log,/srv/gitlab/config:GitLab 的配置文件)
--e:配置 Gitlab 运行的环境变量
[root@master ~]# docker run  -d \
> -h gitlab \
> -p 2222:22 \
> -p 8888:80 \
> -p 8443:443 \
> -v /docker/gitlab/config:/etc/gitlab \
> -v /docker/gitlab/logs:/var/log/gitlab \
> -v /docker/gitlab/data:/var/opt/gitlab \
> --restart always \
> --name gitlab \
> gitlab/gitlab-ce:latest
735b8de9827a615cb69392f542acc33e4fecec998256af62eb9a36e8733cae12
[root@master ~]#

错误信息:502 Whoops, GitLab is taking too much time to respond. 

 

 

 

 

说明gitlab还没有准备好,再等待一会,刷新浏览器,即可看到如下页面 

 

 

 

初次使用gitlab时需要创建默认管理员密码,至少8位,这里输入“12345678”。 
我们在登录那里使用root作为用户名,然后用刚刚设置的密码,就可以以管理员身份登录Gitlab。 

 

 

 

修改gitlab 配置

 

 

查看容器状态

healthy:starting状态

6.修改gitlab.rb配置文件。

vim /home/gitlab/config/gitlab.rb

在gitlab.rb最后加上如下三句,保存

# 配置http协议所使用的访问地址,不加端口号默认为80
external_url 'http://192.168.0.54'
 
# 配置ssh协议所使用的访问地址和端口
gitlab_rails['gitlab_ssh_host'] = '192.168.0.54'
gitlab_rails['gitlab_shell_ssh_port'] = 222 # 此端口是run时22端口映射的222端口

 

当初始页面是登录页面则需要修改初始密码

1,首先需要进入容器

docker exec -it 01829bb92188 /bin/bash

 

2,然后执行以下命令

gitlab-rails console -e production

user = User.where(username:"root").first

user.password = "新密码"

user.password_confirmation ="再次确认密码"

user.save!

执行如图:

 

 

 

关于防火墙的一些配置

systemctl stop firewalld.service --关闭centos防火墙

systemctl disable firewalld.service --防火墙开机关闭

firewall-cmd --state --查询防火墙状态

 

文章参考地址

https://blog.csdn.net/chengyuqiang/article/details/80043436

https://blog.csdn.net/weixin_42610043/article/details/121019945

https://blog.csdn.net/HYZX_9987/article/details/119929043

 


说明gitlab还没有准备好,再等待一会,刷新浏览器,即可看到如下页面 

初次使用gitlab时需要创建默认管理员密码,至少8位,这里输入“12345678”。 我们在登录那里使用root作为用户名,然后用刚刚设置的密码,就可以以管理员身份登录Gitlab。 

posted @ 2022-01-20 08:32  逊老头  阅读(246)  评论(0编辑  收藏  举报