docker-compose部署GitLab私有仓库

GitLab 部署

下载地址:https://nextcloud.itwetouch.com/s/i53xoPmMWCP6fyb

安装docker和compose

执行初始化脚本

./init_docker.sh

注意:给脚本添加执行权限
执行shell可能报错
执行.sh脚本时出现$’\r’: 未找到命令
是因为脚本在windows下编辑过,windows下的换行带有‘\r’而unix或者linux下的换行是‘\n’
解决:yum install -y dos2unix
然后执行命令:dos2unix *.sh

compose-gitlab.yml

/data:/var/opt/gitlab数据目录记得挂载一个存储较大(> 200G)的目录。

version: '3'

services:
  gitlab:
    image: 'gitlab/gitlab-ce:14.10.2-ce.0'
    restart: always                  
    hostname: 'www.mygitlab.com'
    environment:
      TZ: 'Asia/Shanghai'       
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://172.16.0.86:3000'  # web站点访问地址
        gitlab_rails['gitlab_shell_ssh_port'] = 2222
    ports:
      - '3000:3000' # 注意宿主机和容器内部的端口要一致,否则external_url无法访问
      - '8443:443'
      - '2222:22'
    volumes:
      - ./config:/etc/gitlab
      - ./data:/var/opt/gitlab
      - ./logs:/var/log/gitlab
    logging: 
      driver: "json-file"
      options: 
        max-size: "2g"
        max-file: "2"

启动容器

# 启动
docker-compose -f ./compose-gitlab.yml up -d
# 查看是否启动完成,执行以下命令检查容器状态
docker ps -a

容器起来之后,默认用户是root,要登录web界面需要先进入容器的这个文件获取密码:

# 在./config目录下
/etc/gitlab/initial_root_password

# 查看密码
cat ./config/initial_root_password

显示如下

# WARNING: This value is valid only in the following conditions
#          1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
#          2. Password hasn't been changed manually, either via UI or via command line.
#
#          If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

Password: Y1HQINsnNN25SJummB8ZzPsJuYPtJBImTq3cmPDwPzA=

# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
posted @ 2023-02-27 23:58  itwetouch  阅读(102)  评论(0编辑  收藏  举报