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}}"
相关推荐
ltl6 小时前
存储性能建模:IOPS、吞吐与延迟
linux
刘某的Cloud8 小时前
ceph osd 导入导出 rbd volume 卷
linux·运维·ceph·volume
酸菜。10 小时前
dw_axi_dmac总结
linux
神奇霸王龙10 小时前
Agent 准入门控屠夫:5 旗舰 4 维度评估
linux·运维·数据库·ai·ai作画·agent·ai编程
小绫网络安全13 小时前
Kali Linux渗透测试入门教程:从零搭建到实战攻防
linux·运维·服务器
allforgood13 小时前
控制启动过程
linux·运维·服务器
西安景驰电子13 小时前
《PTP精确时间协议系列》第一篇:从原理到应用,全面解读IEEE 1588
linux·运维·服务器·开发语言·网络·windows·php
猫吃了源码14 小时前
k9s简介和安装
linux·docker·kubernetes
小马同学-15 小时前
高可用-Keepalived全解析
linux·运维
Forever Nore15 小时前
LeetCode 13 罗马数字转整数 - 按规则处理
linux·服务器·leetcode