docker 安装gitlab

复制代码
docker pull gitlab/gitlab-ce:15.1.6-ce.0

docker run -d --name gitlab-15.1.6 --hostname localhost -p 8090:80 -p 8443:443 -p 2222:22 --restart unless-stopped --shm-size 256m gitlab/gitlab-ce:15.1.6-ce.0

获取密码

2分钟后先试试

docker exec gitlab-15.1.6 cat /etc/gitlab/initial_root_password

如果显示文件不存在,等待并重试

等看到日志显示 "gitlab Reconfigured!" 后再试

因为在 8090 端口访问,需要配置 GitLab:

复制代码
# 进入容器
docker exec -it gitlab-15.1.6 bash

# 编辑配置文件
vi /etc/gitlab/gitlab.rb

# 添加以下配置:
external_url 'http://localhost:8090'  # 重要:指定你的端口
nginx['listen_port'] = 80
nginx['listen_https'] = false
gitlab_rails['gitlab_shell_ssh_port'] = 2222
gitlab_rails['gitlab_https'] = false

# 保存并退出(vi: 按 Esc,输入 :wq,回车)

# 重新配置
gitlab-ctl reconfigure

# 重启服务
gitlab-ctl restart

# 退出容器
exit

配置全局用户信息

git config --global user.name "你的名字"

git config --global user.email "你的邮箱@example.com"

克隆项目时使用正确的 URL

git clone http://localhost:8090/username/project.git

或使用 SSH(注意端口)

git clone ssh://git@localhost:2222/username/project.git

验证:

测试 HTTP 连接

curl http://localhost:8090

如果 curl 不可用,用 PowerShell

Invoke-WebRequest -Uri "http://localhost:8090" -Method Get

相关推荐
70asunflower2 小时前
Emulation,Simulation,Virtualization,Imitation 的区别?
linux·docker
ShiLiu_mtx3 小时前
k8s - 7
云原生·容器·kubernetes
春日见3 小时前
车辆动力学:前后轮车轴
java·开发语言·驱动开发·docker·计算机外设
xuhe23 小时前
[全流程详细教程]Docker部署ClawBot, 使用GLM4.7, 接入TG Bot实现私人助理. 解决Docker Openclaw Permission Denied问题
linux·docker·ai·github·tldr
星火s漫天4 小时前
第一篇: 使用Docker部署flask项目(Flask + DB 容器化)
数据库·docker·flask
MonkeyKing_sunyuhua6 小时前
docker compose up -d --build 完全使用新代码打包的方法
docker·容器·eureka
醇氧6 小时前
【docker】mysql 8 的健康检查(Health Check)
mysql·docker·容器
技术路上的探险家7 小时前
Ubuntu下Docker与NVIDIA Container Toolkit完整安装教程(含国内源适配)
linux·ubuntu·docker
70asunflower10 小时前
用Docker创建不同的容器类型
运维·docker·容器
小Pawn爷11 小时前
3.Dockerfile
docker