原文地址
https://www.jianshu.com/p/1d552434402a

第一步搭建好docker与docker-compose环境
编写docker-compose.yml文件

version: "3"
services:
  gitlab:
    image: gitlab/gitlab-ce
    container_name: gitlab
    restart: always
    hostname: '192.168.31.230'
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url "http://192.168.31.230:9090"
        gitlab_rails['gitlab_shell_ssh_port'] = 2222
        gitlab_rails['gitlab_email_enabled'] = true
        gitlab_rails['gitlab_email_from'] = 'xxx@xxxxx.com'
        gitlab_rails['gitlab_email_display_name'] = 'xxx'
        gitlab_rails['gitlab_email_reply_to'] = 'xxxx@xxxxx.com'
        gitlab_rails['smtp_enable'] = true
        gitlab_rails['smtp_address'] = "smtp.mxhichina.com"
        gitlab_rails['smtp_port'] = 465
        gitlab_rails['smtp_user_name'] = "xxx@xxxx.com"
        gitlab_rails['smtp_password'] = "xxxxx"
        gitlab_rails['smtp_domain'] = "smtp.mxhichina.com"
        gitlab_rails['smtp_authentication'] = "login"
        gitlab_rails['smtp_enable_starttls_auto'] = true
        gitlab_rails['smtp_openssl_verify_mode'] = 'peer'
        gitlab_rails['smtp_tls'] = true
    ports:
      - '9090:9090'
      - '2222:22'
    volumes:
      - '/srv/gitlab/config:/etc/gitlab'
      - '/srv/gitlab/logs:/var/log/gitlab'
      - '/srv/gitlab/data:/var/opt/gitlab'
    logging:
      driver: "json-file"
      options:
        max-size: "20m"
        max-file: "10"

github项目地址:https://github.com/xvjialing/gitlab_docker-compose

测试

将项目代码克隆下来
将项目中的xxx和一些配置改成自己的设置
在项目根目录下运行docker-compose up -d即可启动gitlab,其中9090为web管理界面访问端口,2222为ssh访问端口。
更新gitlab版本
运行命令docker-compose pull && docker-compose up -d

个人博客:https://blog.xvjialing.xyz
github主页:https://github.com/xvjialing

微信公众号

Docker搭建GitLab
https://segmentfault.com/a/1190000019019854?utm_source=tag-newest

文档更新时间: 2020-06-28 01:22   作者:月影鹏鹏