安装gitlab

发布时间 2023-07-04 16:58:28作者: 我没有领悟

1、新建gitlab目录,并配置环境变量GITLAB_HOME为gitlab目录地址

2、在gitlab目录下,准备docker-compose.yml文件,内容如下:

version: '3.6'
services:
  web:
    image: 'registry.gitlab.cn/omnibus/gitlab-jh:latest'
    container_name: 'gitlab'
    restart: always
    hostname: 'gitlab.example.com'
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://gitlab.example.com:8929'
        gitlab_rails['gitlab_shell_ssh_port'] = 2224
    ports:
      - '8929:8929'
      - '2224: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  (gitlab.example.com可以换成自己的域名)

3、修改配置文件gitlab.rb(在GITLAB_HOME对应地址下的config目录中)

       external_url "http://gitlab.example.com:8929"   // gitlab.example.com可以换成自己的域名
       gitlab_rails['gitlab_shell_ssh_port'] = 2289

4、重启配置

     执行  docker exec -it gitlab /bin/bash 命令进入容器

     执行 gitlab-ctl reconfigure 命令重启配置

5、查询 root用户名 的密码

    docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password

6、访问 http://gitlab.example.com:8929  使用root和步骤5查询的密码登录系统

ps: 官网安装地址 https://docs.gitlab.cn/jh/install/docker.html