Docker-compose部署 gitlab-server

Gitlab部署文档

1、配置环境变量

bash 复制代码
export GITLAB_HOME=/srv/gitlab

2、创建docker-compose.yml文件

  • 修改http端口需要同步修改external_url
  • 修改ssh端口需要同步修改gitlab_rails'gitlab_shell_ssh_port'
  • volumes:容器数据的持久化存储,强烈推荐。除非你希望重启容器就将Gitlab重置
yaml 复制代码
version: '3.6'
services:
  web:
    image: 'registry.gitlab.cn/omnibus/gitlab-jh:latest'
    restart: always
    # 云服务器ip
    hostname: '0.0.0.0' 
    environment:
      # 云服务器地址
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://0.0.0.0:8989' 
        gitlab_rails['gitlab_shell_ssh_port'] = 2222 
    ports:
      # 这里两个端口号都需要改
      - '8989:8989' 
      - '443:443'
      # 修改ssh端口号,需要同步修改gitlab_shell_ssh_port
      - '2222:22' 
    volumes:
      - '$GITLAB_HOME/config:/etc/gitlab'
      - '$GITLAB_HOME/logs:/var/log/gitlab'
      - '$GITLAB_HOME/data:/var/opt/gitlab'
    shm_size: '256m'

使用docker compose up -d 启动

3、获取超级管理员账号密码

方案一:系统自动生成的密码
  • 自动生成的密码只有24小时的保留期限

  • 进入容器内部:docker exec -it ah69c7j89k3f /bin/bash

  • 查看初始密码:cat /etc/gitlab/initial_root_password

  • 以该方法登录后需要修改管理员密码
方案二:重置root密码
  • 如果使用方案一登录无效,则需要使用方案二重置root密码后登录。参考官方文档

进入容器内部:docker exec -it be28b6c5223f /bin/bash

进入rails控制台: gitlab-rails console

查找到root用户:user = User.find_by_username "root"

重置密码:user.password="自己设置一个密码"

保存:user.save!

方案三:重置root密码
bash 复制代码
docker exec -it ah69c7j89k3f /bin/bash
# su - git
$ gitlab-rake "gitlab:password:reset[root]"
Enter password: 
Confirm password: 
Unable to change password of the user with username root.
Password must not contain commonly used combinations of words and letters
$ gitlab-rake "gitlab:password:reset[root]"
Enter password: 
Confirm password: 
Password successfully updated for user with username root.
$
相关推荐
BaiduPHP1 分钟前
docker异常断电,出现docker服务,启动失败
docker·容器·eureka
寒冰碧海2 小时前
大模型部署从0到1(三):单机多卡 vLLM 部署Qwen3.6实战|Docker Compose 一键启动
docker·容器·vllm
chexus4 小时前
Docker 镜像瘦身:使用 Maven 拆分 Jar 包
docker·maven·jar
潘正翔14 小时前
docker核心概念
linux·运维·服务器·docker·容器·centos·运维开发
Java小白笔记17 小时前
Docker 安装配置完全指南:MacOS 、Windows、Linux环境下的安装、配置与验证
linux·macos·docker
copyer_xyf21 小时前
Docker 入门与实战:容器化 React + NestJS 项目
docker
刘马想放假1 天前
Docker 从入门到进阶:一篇写给工程师的系统化实战指南
运维·docker·容器
Wang's Blog1 天前
Go-Zero进阶实战2: 使用 Docker Compose 编排与部署微服务
docker·微服务·golang
zjun30211 天前
如何搭建TRAE IDE 连接到容器开发环境
docker·容器·ascend·trae
寒冰碧海1 天前
大模型部署从0到1(一):通用环境全流程准备|NVIDIA驱动+Docker+NVIDIA Container Toolkit
运维·docker·容器