gitlab(docker)安装及使用

GitLab

GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的Web服务。

下载(docker)

查询docker镜像gitlab-ce

gitlab-ce是它的社区版

shell 复制代码
[root@localhost ~]# docker search gitlab-ce
NAME                                     DESCRIPTION                                      STARS     OFFICIAL   AUTOMATED
rapidfort/gitlab-ce                                                                       12                   
drud/gitlab-ce                                                                            18                   
gitlab/gitlab-ce                         GitLab Community Edition docker image based ...   4043                 [OK]

下载镜像

下载镜像gitlab/gitlab-ce

shell 复制代码
latest: Pulling from gitlab/gitlab-ce
7b1a6ab2e44d: Pull complete 
6c37b8f20a77: Pull complete 
f50912690f18: Pull complete 
bb6bfd78fa06: Pull complete 
2c03ae575fcd: Pull complete 
839c111a7d43: Pull complete 
4989fee924bc: Pull complete 
666a7fb30a46: Downloading [=================================>                 ]  662.1MB/995.5MB

启动安装docker容器

创建gitlab文件夹

shell 复制代码
[root@localhost softwares]# mkdir gitlab
[root@localhost softwares]# ll
总用量 0
drwxr-xr-x. 2 root root   6 10月 28 10:24 gitlab
drwxr-xr-x. 3 root root  60 9月  23 23:41 jdk
drwxr-xr-x. 4 root root  30 9月  24 23:44 mysql
drwxr-xr-x. 5 root root 109 9月  24 17:44 nexus
drwxr-xr-x. 4 root root  42 10月 22 22:17 redis
[root@localhost softwares]# pwd
/usr/local/softwares

创建config,logs,data文件夹

shell 复制代码
[root@localhost gitlab]# mkdir config logs data
[root@localhost gitlab]# tree
.
├── config
├── data
└── logs

创建运行容器

shell 复制代码
docker run -it \
--hostname wnhz-gitlab.com \
--name gitlab \
-p 443:443 -p 80:80 -p 23:22 \
--network wn_docker_net \
--ip 172.18.12.50 \
-v /usr/local/softwares/gitlab/config:/etc/gitlab \
-v /usr/local/softwares/gitlab/logs:/var/log/gitlab \
-v /usr/local/softwares/gitlab/data:/var/opt/gitlab \
-d gitlab/gitlab-ce
shell 复制代码
[root@localhost gitlab]# docker ps
CONTAINER ID   IMAGE              COMMAND                   CREATED         STATUS                            PORTS                                                                                                         NAMES
cf0f38c6f0a4   gitlab/gitlab-ce   "/assets/wrapper"         4 seconds ago   Up 3 seconds (health: starting)   0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp, 0.0.0.0:23->22/tcp, :::23->22/tcp   gitlab

gitlab配置

访问http://192.168.198.128/ linux主机地址

设置用户名密码

命令行:docker exec -it gitlab bash 进入容器

输入命令行 gitlab-rails console
shell 复制代码
[root@localhost gitlab]# docker exec -it gitlab bash
root@cf0f38c6f0a4:/# gitlab-rails console
输入用户名密码存储

user=User.find_by_username 'root'

user.password='88888888'

user.save!

ruby 复制代码
Loading production environment (Rails 6.1.4.1)
irb(main):001:0> user=User.find_by_username 'root'
=> #<User id:1 @root>
irb(main):004:0> user.password='88888888'
=> "88888888"
irb(main):005:0> user.save!
=> true

登录

使用设置的用户名,密码登录

Gitlab设置

关闭自动注册功能

  1. Menu->Admin
  1. Settings->Geneal->Sign-up restrictions

  2. 禁止注册

创建用户User

在Admin下点击Admin Area --> Users

创建用户: New user

编辑用户信息

给指定用户添加密码

使用新用户登录
第一次登录强制要求修改密码


修改个人信息

优化gitlab占用内存

进入gitlab容器

使用root用户登录

shell 复制代码
 docker exec -it gitlab bash
进入etc/gitlab文件夹
修改gitlab.rb文件

tips: 如果容器中不能使用vim命令,使用 apt-get update , apt-get install vim安装

  • gitlab_rails['env']

    shell 复制代码
     597 gitlab_rails['env'] = {
     598    'MALLOC_CONF' => 'dirty_decay_ms:1000,muzzy_decay_ms:1000'
     599 #    "SKIP" => "db,uploads,repositories,builds,artifacts,lfs,registry,pages"
     600 }
  • 'worker_processes'

    禁用 puma cluster 模式

    shell 复制代码
     974 puma['worker_timeout'] = 60
     975 puma['worker_processes'] = 0
  • sidekiq

    shell 复制代码
    1018 sidekiq['max_concurrency'] = 10
重启容器
  1. 配置生效

在容器中输入: gitlab-ctl reconfigure

shell 复制代码
root@192:/etc/gitlab# gitlab-ctl reconfigure
  1. 重启容器

在容器内输入:gitlab-ctl restart 重启容器。

shell 复制代码
root@192:/etc/gitlab# gitlab-ctl restart
查询gitlab的内存占用

docker stats gitlab

idea使用gitlab

在gitLab上创建仓库

idea使用gitlab错误

error: unable to read askpass response from 'C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2021.3\tmp\intellij-git-askpass-local.sh'

解决方案: 修改项目隐藏.git下的config文件,添加gitlab用户名密码

rom 'C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2021.3\tmp\intellij-git-askpass-local.sh'

外链图片转存中...(img-T4YqWwcg-1713174221296)

解决方案: 修改项目隐藏.git下的config文件,添加gitlab用户名密码

外链图片转存中...(img-j8DfMdIM-1713174221296)

外链图片转存中...(img-26rFhQvk-1713174221296)

相关推荐
明月心9521 天前
git remote add 用法
gitlab
only_Klein1 天前
jenkins流水线报错:Connection reset by peer
ci/cd·kubernetes·gitlab·jenkins·ssl
梁萌2 天前
docker部署gitlab和gitlab runner
docker·eureka·gitlab
johnnyAndCode2 天前
Idea 设置GitLab时使用账密,而不是token的配置方法
gitlab·idea
天外飞雨2 天前
Gitlab使用
gitlab
BUTCHER53 天前
GitLab SSH 密钥配置
运维·ssh·gitlab
明月心9523 天前
GitLab使用
gitlab
明月心9524 天前
gitlab pull requets
gitlab
BUTCHER54 天前
GitLab基本设置
gitlab
张小凡vip4 天前
Kubernetes---gitlab的ci/cd发布基于k8s的项目示例参考
ci/cd·kubernetes·gitlab