ubuntu安装gitlab

gitlab安装方式

0.创建所需文件夹,这个/data/gitlab/gitlab-ce/可以是任意路径,一般不要放在系统盘,这个要和2中的对应

复制代码
sudo mkdir -p /data/gitlab/gitlab-ce/gitlab/{config,data,logs}

cd到gitlab目录层级,sudo chmod 755 gitlab 赋予权限

1.拉去docker镜像 最新的就行,并load载入,

复制代码
docker pull gitlab/gitlab-ce:latest

2.运行下面代码

复制代码
sudo docker run -itd \
 --name gitlab \
 --restart always \
 --memory 16g \
 --memory-swap 24g \
 --shm-size 512m \
 -p 8880:80 \
 -p 8443:443 \
 -p 2222:22 \
 -v /data/gitlab/gitlab-ce/gitlab/config:/etc/gitlab \
 -v /data/gitlab/gitlab-ce/gitlab/logs:/var/log/gitlab \
 -v /data/gitlab/gitlab-ce/gitlab/data:/var/opt/gitlab \
 --privileged=true \
 gitlab/gitlab-ce:latest

3.运行下面的查看gitlab初始密码,用户名为root,第一次登录要用

复制代码
docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password

4.修改配置,cd到gitlab目录下,依次运行:

复制代码
vim gitlab/config/gitlab.rb
external_url 'http://gitlab.yourdomain.com'  # 替换为实际域名或IP
gitlab_rails['gitlab_shell_ssh_port'] = 2222  # 匹配容器映射端口

5.运行下面的完成安装

复制代码
docker exec -it gitlab gitlab-ctl reconfigure
docker restart gitlab

6.登录方式:ip:80的映射端口,此处为ip:8880

7.若登录不了,处理下防火墙

复制代码
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 2222/tcp  # GitLab SSH端口
sudo ufw reload

8.设置cron任务自动备份:

复制代码
0 2 * * * docker exec -t gitlab gitlab-backup create

9.查看端口映射方式,确保Docker运行命令正确映射了端口(特别是80和443):

复制代码
docker ps --format "table {{.Names}}\t{{.Ports}}"
相关推荐
Johny_Zhao8 小时前
OpenClaw安装部署教程
linux·人工智能·ai·云计算·系统运维·openclaw
chlk1232 天前
Linux文件权限完全图解:读懂 ls -l 和 chmod 755 背后的秘密
linux·操作系统
舒一笑2 天前
Ubuntu系统安装CodeX出现问题
linux·后端
改一下配置文件2 天前
Ubuntu24.04安装NVIDIA驱动完整指南(含Secure Boot解决方案)
linux
深紫色的三北六号2 天前
Linux 服务器磁盘扩容与目录迁移:rsync + bind mount 实现服务无感迁移(无需修改配置)
linux·扩容·服务迁移
SudosuBash2 天前
[CS:APP 3e] 关于对 第 12 章 读/写者的一点思考和题解 (作业 12.19,12.20,12.21)
linux·并发·操作系统(os)
哈基咪怎么可能是AI3 天前
为什么我就想要「线性历史 + Signed Commits」GitHub 却把我当猴耍 🤬🎙️
linux·github
十日十行4 天前
Linux和window共享文件夹
linux
木心月转码ing4 天前
WSL+Cpp开发环境配置
linux
崔小汤呀5 天前
最全的docker安装笔记,包含CentOS和Ubuntu
linux·后端