Docker-compose部署gitlab中文版

安装 docker并设置加速器
#安装必要工具
yum -y install yum-utils device-mapper-persistent-data lvm2 net-tools 
#添加软件源信息
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
#如果上步操作报错,内容如下:
-bash: yum-config-manager: 未找到命令
#处理方法:
yum install -y yum-utils
#更新并安装 Docker-CE
yum makecache fast
yum -y install docker-ce
#开启并查看Docker服务
systemctl start docker
systemctl status docker
#设置docker开机自启动
systemctl enable docker
#查看docker版本信息
docker version
#添加Docker镜像加速
vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://9w1hl6qt.mirror.aliyuncs.com"]
}
#重置docker后台进程并重启docker服务
systemctl daemon-reload
systemctl restart docker

安装Docker-compose

#下载Docker-compose二进制文件
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版本信息
docker-compose --version

安装Gitlab

#创建 gitlab 的 docker-compose.yml 存放路径
mkdir -p /data/gitlab && cd /data/gitlab

#编辑docker-compose的yml文件
version: ‘2‘
services:
    gitlab:
      image: ‘twang2218/gitlab-ce-zh:11.1.4‘
      restart: always
      container_name: "gitlab"
      #privileged: true  #特权模式
      hostname: ‘gitlab‘
      environment:
        TZ: ‘Asia/Shanghai‘
        GITLAB_OMNIBUS_CONFIG: |
          external_url ‘http://192.168.246.194‘
          gitlab_rails[‘time_zone‘] = ‘Asia/Shanghai‘
          gitlab_rails[‘gitlab_shell_ssh_port‘] = 58522
          gitlab_rails[‘smtp_enable‘] = true
          gitlab_rails[‘smtp_address‘] = "smtp.163.com"
          gitlab_rails[‘smtp_port‘] = 465
          gitlab_rails[‘smtp_user_name‘] = ""  #用自己的163邮箱
          gitlab_rails[‘smtp_password‘] = "xxxxxxxx"  #自己的163邮箱密码
          gitlab_rails[‘smtp_domain‘] = "163.com"
          gitlab_rails[‘smtp_authentication‘] = "login"
          gitlab_rails[‘smtp_enable_starttls_auto‘] = true
          gitlab_rails[‘smtp_tls‘] = true
          gitlab_rails[‘gitlab_email_from‘] = ‘‘ #用自己的163邮箱
      ports:
        - ‘80:80‘
        - ‘443:443‘
        - ‘58522:22‘
      volumes:
        - /opt/gitlab/config:/etc/gitlab
        - /opt/gitlab/data:/var/opt/gitlab
        - /opt/gitlab/logs:/var/log/gitlab
#创建相关目录
mkdir /opt/gitlab/{config,data,logs} -p
#查看创建的目录
ll /opt/gitlab
总用量 0
drwxr-xr-x 2 root root 6 3月  23 11:14 config
drwxr-xr-x 2 root root 6 3月  23 11:14 data
drwxr-xr-x 2 root root 6 3月  23 11:14 logs
#拉取gitlab中文版镜像
docker pull twang2218/gitlab-ce-zh:11.1.4
#启动gitlab的容器
docker-compose -f /data/gitlab/docker-compose.yml up -d
#查看服务状态
docker-compose ps
 Name        Command          State                                    Ports
---------------------------------------------------------------------------------------------------------
gitlab   /assets/wrapper   Up (healthy)   0.0.0.0:58522->22/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp

gitlab设置开机启动

在vim /etc/rc.d/rc.local添加:

/usr/local/bin/docker-compose -f /data/gitlab/docker-compose.yml up -d

gitlab管理界面

地址:http://192.168.246.194

账号:root

密码:首次登陆设置

Docker-compose部署gitlab中文版
Docker-compose部署gitlab中文版

相关推荐