鉴于现在的大部分公司都会使用Gitlab作为自己的代码仓库,有必要搭建起来玩一玩。以下完全是自己的实践结果,并已应用于20~30人团队的使用中,目前系统运行比价稳定,就是有点吃内存。
gitlab-ce是它的社区版
[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
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
[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
[root@localhost gitlab]# mkdir config logs data
[root@localhost gitlab]# tree
.
├── config
├── data
└── logs
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
[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
访问http://192.168.198.128/ linux主机地址
命令行:docker exec -it gitlab bash 进入容器
[root@localhost gitlab]# docker exec -it gitlab bash
root@cf0f38c6f0a4:/# gitlab-rails console
user=User.find_by_username ‘root’
user.password=‘88888888’
user.save!
Loading production environment (Rails 6.1.4.1)
irb(main):001:0> user=User.find_by_username 'root'
=> #
irb(main):004:0> user.password='88888888'
=> "88888888"
irb(main):005:0> user.save!
=> true
使用设置的用户名,密码登录
在Admin下点击Admin Area --> Users
创建用户: New user
编辑用户信息
使用新用户登录
第一次登录强制要求修改密码
使用root用户登录
docker exec -it gitlab bash
tips: 如果容器中不能使用vim命令,使用 apt-get update , apt-get install vim安装
gitlab_rails[‘env’]
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 模式
974 puma['worker_timeout'] = 60
975 puma['worker_processes'] = 0
sidekiq
1018 sidekiq['max_concurrency'] = 10
在容器中输入: gitlab-ctl reconfigure
root@192:/etc/gitlab# gitlab-ctl reconfigure
在容器内输入:gitlab-ctl restart 重启容器。
root@192:/etc/gitlab# gitlab-ctl restart
docker stats 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-WGsPnXox-1703410195225)]
解决方案: 修改项目隐藏.git下的config文件,添加gitlab用户名密码
[外链图片转存中…(img-aedxGTVv-1703410195226)]
[外链图片转存中…(img-1lhcN67n-1703410195226)]