如何使用Docker搭建Gitlab私有库

第一步、安装环境

Node IP Descprition
Gitlab 192.168.50.102 Gitlab服务

域名:www.example.com

第二步、安装Docker

Linux安装Docker教程

第三步、使用Dokcer部署Gitlab

1、创建挂载目录

配置文件

mkdir /opt/docker/gitlab-ce/config

数据文件

mkdir /opt/docker/gitlab-ce/data

日志文件

mkdir /opt/docker/gitlab-ce/logs

证书文件(用于开启https)

mkdir /opt/docker/gitlab-ce/certs

文件夹赋权

chmod 777 -R /opt/docker/gitlab-ce

2、创建docker-compose.yml

vi /opt/docker/gitlab-ce/docker-compose.yml

文件内容如下

version: '2'
services:
    gitlab:
      container_name: "gitlab-ce-zh"
      image: 'twang2218/gitlab-ce-zh:latest'
      restart: always
      hostname: '192.168.50.102'
      environment:
        TZ: 'Asia/Shanghai'
        GITLAB_OMNIBUS_CONFIG: |
          external_url 'http://www.example.com:3080'
          # external_url 'https://www.example.com:3443' # 开启https
          gitlab_rails['time_zone'] = 'Asia/Shanghai'
          gitlab_rails['gitlab_shell_ssh_port'] = 3022
          gitlab_rails['gitlab_ssh_host'] = 'www.example.com'

          # nginx配置(开启ssl)
          # nginx['enable'] = true
          # nginx['listen_port'] = 3443
          # nginx['redirect_http_to_https'] = true
          # nginx['redirect_http_to_https_port'] = 30080
          # nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.talkmu.com.pem"
          # nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.talkmu.com.key"
          # nginx['ssl_protocols'] = "TLSv1.1 TLSv1.2"
      ports:
        - '3080:3080'
        - '3443:3443'
        - '30022:22'
      volumes:
        - /opt/docker/gitlab-ce/config:/etc/gitlab
        - /opt/docker/gitlab-ce/data:/var/opt/gitlab
        - /opt/docker/gitlab-ce/logs:/var/log/gitlab
        - /opt/docker/gitlab-ce/certs:/etc/gitlab/ssl

3、启动容器

cd /opt/docker/gitlab-ce
docker-compose up -d

如何使用Docker搭建Gitlab私有库_第1张图片
在这里插入图片描述

4、访问服务

http://www.example.com:3080

如何使用Docker搭建Gitlab私有库_第2张图片

你可能感兴趣的:(Docker,docker,gitlab,运维)