docker-compose部署gitlab
Posted 草根追逐
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker-compose部署gitlab相关的知识,希望对你有一定的参考价值。
安装前的准备准备
如果本机是首次使用docker-compose环境部署,需要在在/deploy/sorts创建以下脚本并执行
vi pre_install.sh
vi pre_install.sh
#!/bin/bash
###关闭selinux
sed -i \'s/SELINUX=enforcing/SELINUX=disabled/g\' /etc/selinux/config
setenforce 0
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum -y install docker-ce
###配置拉取国内镜像仓库
tee /etc/docker/daemon.json <<-\'EOF\'
{
"registry-mirrors": [
"https://5sr5uink.mirror.aliyuncs.com",
"https://docker.mirrors.ustc.edu.cn",
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com"
],
"insecure-registries": ["harbor.xxx.com"]
}
EOF
###启动docker
systemctl start docker
systemctl enable docker
### 下载docker-compose
curl -L "https://get.daocloud.io/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/bin/docker-compose
chmod +x /usr/bin/docker-compose
docker-compose -version
sh pre_install.sh
创建gitlab目录和相关子目录
mkdir /deploy/sorts/gitlab
cd /deploy/sorts/gitlab
mkdir data log conf
创建yml编排文件
vi docker-compose.yml
version: "3.7"
services:
gitlab:
image: \'harbor.xxx.com/xxx/gitlab-ce:13.10.3-ce.0\'
restart: always
hostname: \'gitlab\'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url \'http://10.10.10.203\'
# Add any other gitlab.rb configuration here, each on its own line
ports:
- \'80:80\'
- \'443:443\'
- \'22365:22\'
volumes:
- \'./conf:/etc/gitlab\'
- \'./logs:/var/log/gitlab\'
- \'./data:/var/opt/gitlab\'
其中
external_url链接如果你有外网域名就写gitlab对应的外网域名地址,如果没有就写gitlab内网地址
22365代表的是gitlab内部的的ssh端口对外映射成22365端口
创建启动脚本和停止脚本
vi up.sh
#!/bin/bash
set -e
tm=`date +%Y%m%d-%H%M%S`
echo "====================================================="
echo "Starting gitlab."
echo "Starting <${tm}>."
echo "====================================================="
echo "Please ensure the config files right."
echo "====================================================="
docker-compose -p gitlab up -d
vi down.sh
#!/bin/bash
set -e
tm=`date +%Y%m%d-%H%M%S`
echo "====================================================="
echo "Stopping gitlab."
echo "Stopping <${tm}>."
echo "====================================================="
echo "Please ensure the config files right."
echo "====================================================="
docker-compose -p gitlab down
启动gitlab
sh up.sh
[root@localhost-203-root-all gitlab]# docker-compose ps
Name Command State Ports
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
gitlab_gitlab_1 /assets/wrapper Up (health: starting) 0.0.0.0:22365->22/tcp,:::22365->22/tcp, 0.0.0.0:443->443/tcp,:::443->443/tcp, 0.0.0.0:80->80/tcp,:::80->80/tcp
登陆gitlab
浏览器输入gitlab所在节点的IP即可访问
其中
账号为root
密码首次登陆会提醒你设置
以上是关于docker-compose部署gitlab的主要内容,如果未能解决你的问题,请参考以下文章