Docker搭建Gitlab服务器
1、Gitlab镜像
docker search gitlab
docker search gitlab-ce
docker pull gitlab/gitlab-ce
2、创建容器
# 启动容器
80和443保留默认,22跟宿主机SSH冲突,改为2222
sudo docker run --detach \
--hostname 192.168.1.143 \
--publish 443:443 --publish 80:80 --publish 2222:22 \
--name gitlab \
--restart always \
-v /usr/local/gitlab/config:/etc/gitlab \
-v /usr/local/gitlab/logs:/var/log/gitlab \
-v /usr/local/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest
修改gitlab.rb文件
vi /usr/local/gitlab/config/gitlab.rb
找到external_url,默认是被注释的,要打开
external_url 'http://192.168.1.143'
gitlab_rails['gitlab_shell_ssh_port'] = '2222'
停止并移除之前启动的gitlab
docker rm -f gitlab
重新启动gitlab
docker run --detach \
--hostname 192.168.1.143 \
--publish 443:443 --publish 80:80 --publish 2222:22 \
--name gitlab \
--restart always \
-v /usr/local/gitlab/config:/etc/gitlab \
-v /usr/local/gitlab/logs:/var/log/gitlab \
-v /usr/local/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest
可能的报错:
iptables: No chain/target/match by that name.
external_url '192.168.1.143' 修改为external_url 'http://192.168.1.143'
原因:修改了iptables规则后,重启了iptables,但没有重启docker
解决方案:重启docker :systemctl restart docker
3、浏览器访问
路径访问:http://192.168.1.143
# 机器配置要大于4g,否则很容易启动不了,报502 也有可能内存够大,但服务还正在启动,大概1分来钟
# 第一次访问,会让修改root密码
# 修改后以root用户登录即可
4、查看、修改root密码
查看 root 密码
docker exec -it gitlab cat /etc/gitlab/initial_root_password
[root@localhost ~]# cat /etc/gitlab/initial_root_password
# WARNING: This value is valid only in the following conditions
# 1. If provided manually (either via `GITLAB_ROOT_PASSWORD`
environment variable or via `gitlab_rails['initial_root_password']`
setting in `gitlab.rb`, it was provided before database was seeded for
the first time (usually, the first reconfigure run).
# 2. Password hasn't been changed manually, either via UI or
via command line.
#
# If the password shown here doesn't work, you must reset the
admin password following
https://docs.gitlab.com/ee/security/reset_user_password.html#reset-yourroot-password.
Password: dpzQFzltaq0BhAwDnugMf6MCFbvItXDvC+RcuN9R+wg=
# NOTE: This file will be automatically deleted in the first reconfigure
run after 24 hours.
修改root密码
在GitLab首页,点击右上角【头像】然后点击【设置】。 Edit Profile
忘记密码重置
# 进入容器内部
docker exec -it gitlab /bin/bash
# 进入Rails控制台 1-2分钟
gitlab-rails console -e production
等待执行完,会进入输入模式
# 查询id为1的用户,id为1的用户是超级管理员
user = User.where(id:1).first
# 修改密码为lhx123456
user.password='lhx123456'
user.password_confirmation = 'lhx123456'
# 保存
user.save!
# 退出
exit
//第一个默认为root
user = User.where(id: 1).first
//必须同时更改密码和password_confirmation才能使其正常工作
user.password = '新的密码'
user.password_confirmation = '新的密码'
将下载的RuoYi-Cloud代码上传到gitlab
若依 / RuoYi-Cloud
https://gitee.com/y_project/RuoYi-Cloud/tree/v3.6.1
使用idea方便后面管理
VCS 中选中Create Git Repository(创建本地仓库)
★如果未出现git选项,检查Idea是否未检测到git客户端
windows安装git客户端
https://blog.csdn.net/weixin_42188778/article/details/124523898
gitlab创建一个项目
http://192.168.1.143/root/ruoyi-cloud.git
标签:gitlab,--,KubeSphere,Gitlab,ruoyi,user,docker,password,root From: https://www.cnblogs.com/st2021/p/17066843.html