docker-compose 部署gitlab

首先需要安装docker和docker-compose

yum install -y wget
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
yum -y install docker-ce-18.06.1.ce-3.el7
mkdir -p /etc/docker/
docker --version
#docker镜像加速器
cat >/etc/docker/daemon.json << EOF
{
  "registry-mirrors": ["https://b9pmyelo.mirror.aliyuncs.com"],
"insecure-registries": ["https://repo.rdvalidasi.com"],
"log-driver":"json-file", "log-opts": {"max-size":"200m", "max-file":"10"} } EOF systemctl enable docker && systemctl start docker docker info curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose

 

编写docker-compose.yml

version: '3'
services:
    gitlab:
      image: 'twang2218/gitlab-ce-zh:11.1.4'  # 镜像版本
      #image: 'gitlab/gitlab-ce'              # 镜像版本,也可以是官方的镜像
      container_name: "gitlab"
      restart: unless-stopped
      privileged: true
      hostname: 'gitlab'                      #主机名,要跟主机名一直
      environment:
        TZ: 'Asia/Shanghai'
        GITLAB_OMNIBUS_CONFIG: |
         external_url 'http://192.168.10.216'         # 服务器本地IP地址
         gitlab_rails['time_zone'] = 'Asia/Shanghai'  # 时区
         #gitlab_rails['smtp_enable'] = true          # 下面是否开启邮箱验证
         #gitlab_rails['smtp_address'] = "smtp.xxx.com"
         #gitlab_rails['smtp_port'] = 465
         #gitlab_rails['smtp_user_name'] = "xxx@xxx.com"
         #gitlab_rails['smtp_password'] = "xxxxxx"
         #gitlab_rails['smtp_domain'] = "xxx.com"
         #gitlab_rails['smtp_authentication'] = "login"
         #gitlab_rails['smtp_enable_starttls_auto'] = true
         #gitlab_rails['smtp_tls'] = true
         #gitlab_rails['gitlab_email_from'] = 'xxxx@xxx.com'
         gitlab_rails['gitlab_shell_ssh_port'] = 222   # gitlab远程执行的端口
         nginx['listen_port'] = 80
      ports:
        - '80:80'
        - '443:443'
        - '222:22'
      volumes:
        - /opt/gitlab/config:/etc/gitlab
        - /opt/gitlab/data:/var/opt/gitlab
        - /opt/gitlab/logs:/var/log/gitlab
      logging:
          driver: "json-file"
          options:
              max-size: "200m"
              max-file: "10"

 

启动

docker-compose -f docker-compose.yml up -d

需要等待2-4分钟左右,也看机器的配置情况

 

posted @ 2022-01-15 15:13  缺个好听的昵称  阅读(25)  评论(0编辑  收藏  举报