惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
G
Google Developers Blog
有赞技术团队
有赞技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Blog — PlanetScale
Blog — PlanetScale
罗磊的独立博客
博客园 - 聂微东
V
Visual Studio Blog
博客园_首页
D
DataBreaches.Net
腾讯CDC
I
InfoQ
F
Fortinet All Blogs
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 【当耐特】
Google DeepMind News
Google DeepMind News
人人都是产品经理
人人都是产品经理
云风的 BLOG
云风的 BLOG
月光博客
月光博客
Recent Announcements
Recent Announcements
MongoDB | Blog
MongoDB | Blog
C
Check Point Blog

博客园 - zakun

适配 WSL 的 proxy 完整脚本 Gitlab CI 本地开发部署 Golang grpc 实践 Mongo 聚合演示 真・一键激活 JetBrains 全家桶! Kafka 分区细说 解决国内Homebrew安装 Homebrew How to Install PHP Install Elasticsearch with Docke wsl2 网络相关设置 php docker image nginx 反向代理常用设置说明 Golang常见的并发模式 Gin框架的几种热加载方法 协程 Mysql Full-Text Index 介绍 gitlab runner 使用摘要 Docker 简介 linux-查看文件夹大小 Linux 如何删除乱码文件-inode删除 Nginx反爬虫: 禁止某些User Agent抓取网站 PHP添加$_SERVER服务器环境变量
Gitlab Docker 使用摘要
zakun · 2023-11-24 · via 博客园 - zakun

官方文档: https://docs.gitlab.com/ee/install/docker.html#expose-gitlab-on-different-ports

设置本地目录

  • 设置环境变量 GITLAB_HOME
    • export GITLAB_HOME=/srv/gitlab

安装

  • 启动脚本start.sh
#!/bin/bash

export GITLAB_HOME=/srv/gitlab

sudo docker run --detach \
  --privileged \
  --hostname gitlab.example.com \
  --publish 8980:8980 --publish 8922:22 \
  --name gitlab \
  --network bridge \
  --volume $GITLAB_HOME/config:/etc/gitlab:Z \
  --volume $GITLAB_HOME/logs:/var/log/gitlab:Z \
  --volume $GITLAB_HOME/data:/var/opt/gitlab:Z \
  --shm-size 256m \
  gitlab/gitlab-ee:latest

配置

配置文件位置: /etc/gitlab/gitlab.rb

务必保证 /etc/gitlab/gitlab.rb 配置文件中的 external_url 是真实有效的可访问的地址

重启使配置生效

sudo docker restart gitlab

使用非默认端口

Gitlab 默认使用 80, 443, 22 等端口, 若不使用默认端口,则需修改配置文件 /etc/gitlab/gitlab.rb

若设置Web 端口

# For HTTP
external_url "http://gitlab.example.com:8929"

# or

# For HTTPS (notice the https)
# external_url "https://gitlab.example.com:8929"

若设置ssh端口

gitlab_rails['gitlab_shell_ssh_port'] = 2289

重新配置gitlab

gitlab-ctl reconfigure

重置root密码

首先需要登录gitlab容器内部,如果gitlab容器的名称为 gitlab, 进入容器 docker exec -it gitlab bash

Use a Rake task

gitlab-rake "gitlab:password:reset"

Use a Rails console

  1. 打开rails控制台

    gitlab-rails console
    
  2. 查找用户

    • By username

      user = User.find_by_username 'root'

    • By user ID(root 用户id为1)

      user = User.find(1)

    • By email address

      user = User.find_by(email: 'root@example.com')

  3. 重置密码

    • 设置随机密码

      new_password = ::User.random_password
      user.password = new_password
      user.password_confirmation = new_password
      user.password_automatically_set = false
      
    • 设置指定密码

      new_password = 'examplepassword'
      user.password = new_password
      user.password_confirmation = new_password
      user.password_automatically_set = false
      
  4. 保存

    user.save!
    
  5. 退出

    exit
    

Troubleshooting

  1. Email confirmation issues

If the new password doesn’t work, it might be an email confirmation issue. You can attempt to fix this issue in a Rails console. For example, if a new root password isn’t working:

  • Start a Rails console.
  • Find the user and skip reconfirmation:
user = User.find(1)
user.skip_reconfirmation!
  • Attempt to sign in again