centos7+docker+docker-compose+nginx+gitlab笔记

一、安装虚拟机VMware

下载地址:https://www.onlinedown.net/soft/2062.htm 点击下载

镜像库地址:http://mirrors.163.com/centos/7.9.2009/isos/x86_64/

二、虚拟机IP静态化处理

我的gitlab虚拟机地址:192.168.1.101
nginx 虚拟机地址:192.168.1.100

https://blog.csdn.net/u014467089/article/details/115277316

三、安装docker

curl -sSL https://get.daocloud.io/docker | sh

#启动 docker
sudo systemctl start docker

#查看docker版本
docker -v

#设置docker开机自启动
systemctl enable docker

centos7+docker+docker-compose+nginx+gitlab笔记_第1张图片
docker开机启动

四、安装docker-compose

1.29.1是docker-compose当前的最新版本

具体参考:https://www.runoob.com/docker/docker-compose.html

# 安装,失败-拒绝连接就对重复执行几次
sudo curl -L https://github.com/docker/compose/releases/download/1.29.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

# 将可执行权限应用于二进制文件
sudo chmod +x /usr/local/bin/docker-compose

# 测试是否安装成功
docker-compose --version

五、安装 汉化版 gitlab

# docker search gitlab

centos7+docker+docker-compose+nginx+gitlab笔记_第2张图片
原英文版可以安装最新版
汉化版目前知道 11,查看镜像版本:twang2218/gitlab-ce-zh 镜像

下载镜像

docker pull twang2218/gitlab-ce-zh

使用docker-compose方式安装gitlab

子一个自己喜欢的文件夹下创建挂载文件夹 ,我新加了一个panda

mkdir panda
cd panda
mkdir gitlab
cd gitlab
mkdir {cmd,config,data.logs} -p

新建 vi /panda/gitlab/cmd/docker-compose.yml

version: '2'
services:
    gitlab:
      image: 'twang2218/gitlab-ce-zh'
      container_name: "gitlab-zh"
      restart: always
      privileged: true
      hostname: 'gitlab'
      environment:
        TZ: 'Asia/Shanghai'
        GITLAB_OMNIBUS_CONFIG: |
          external_url 'http://192.168.1.101:8001'
          gitlab_rails['smtp_enable'] = true
          gitlab_rails['smtp_address'] = "smtp.163.com"
          gitlab_rails['smtp_port'] = 465
          gitlab_rails['smtp_user_name'] = "[email protected]"
          gitlab_rails['smtp_password'] = "xxxx"
          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'] = '[email protected]'
          gitlab_rails['gitlab_shell_ssh_port'] = 222
          nginx['redirect_http_to_https_port'] = 8001
          nginx['listen_port'] = 8001
      ports:
        - '8001:8001'
        - '8443:443'
        - '222:22'
      volumes:
        - /panda/gitlab/config:/etc/gitlab
        - /panda/gitlab/data:/var/opt/gitlab
        - /panda/gitlab/logs:/var/log/gitlab

切换打 docker-compose.yml所在目录下,执行

docker-compose up -d

gitlab启动内存至少2G,启动过程比较耗时,耐心等待

docker ps
在这里插入图片描述

访问 http://192.168.1.101:8001/

提示安装ssh秘钥
打开 git bash

 ssh-keygen -t rsa -C '[email protected]'
 # 然后 一路回车,创建SHA256公钥
 
#获取公钥
 cat ~/.ssh/id_rsa.pub

把结果全部赋值过去填写,保存

六、安装nginx

下载,创建挂载目录

docker search nginx
docker pull nginx

mkdir /panda/nginx/vol/{conf,conf.d,html,logs} -p
mkdir /panda/nginx/cmd - p

你可能感兴趣的:(虚拟机,docker,gitlab)