Ubuntu22.04 CI/CD jenkins+harbor+gitlab+docker 搭建

(一) 部署docker

1.更新系统:

sudo apt -y update

2.安装依赖项:

sudo apt -y install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

3.安装Docker ce

导入存储库密钥:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/docker-archive-keyring.gpg

将Docker CE存储库添加到Ubuntu:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

 安装Docker ce:

sudo apt update

sudo apt install docker-ce docker-ce-cli containerd.io

将用户添加到docker组:


sudo usermod -aG docker $USER

newgrp docker

设置docker开机启动

# 启动
systemctl start docker

# 开机启动
systemctl enable docker

安装docker compose:

sudo curl -L "https://github.com/docker/compose/releases/download/1.25.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose 

设置权限:

chmod +x /usr/local/bin/docker-compose

查看版本:

docker-compose --version

(二)部署Harbor

1.下载Harbor安装文件

apt -y install wget
mkdir -p /harbor
cd /harbor
wget -c https://github.com/goharbor/harbor/releases/download/v2.3.2/harbor-offline-installer-v2.3.2.tgz
tar xvf harbor-offline-installer-v2.3.2.tgz

2.配置Harbor
进入解压后的harbor目录 cd harbor 编辑harbor文件,主要修改内容如下:

mv harbor.yml.tmp harbor.yml
hostname = 改为服务器IP

取消https
# https related config#https:
# https port for harbor, default is 443
# port: 443
# The path of cert and key files for nginx
# certificate: /your/certificate/path#private_key: /your/private/key/path

若需要https则nginx ssl需要设置on

root用户默认密码为root123,admin登录密码为Harbor12345

3.启动harbor

./install.sh 

4.修改docker service

vim /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -H fd:// 
后面添加 
--insecure-registry http://服务器IP

(三)安装gitlab

1.拉取镜像:

docker pull gitlab/gitlab-ce

2.安装

docker run  --detach \   
-p 8443:443     -p 8090:80 \   
--name gitlab  \
--restart unless-stopped   \
-v /mnt/gitlab/etc:/etc/gitlab   \
-v /mnt/gitlab/log:/var/log/gitlab   \
-v /mnt/gitlab/data:/var/opt/gitlab   \  
beginor/gitlab-ce

3.进入网页设置初始密码

(四)安装Jenkins

 0.安装jdk:

sudo apt install openjdk-17-jdk

1.安装Jenkins:

docker run -d --name jenkins -p 8040:8080 -p 50000:50000 -v /data/jenkins_home:/var/jenkins_home jenkins/jenkins:lts

2.获取初始密码:

Ubuntu22.04 CI/CD jenkins+harbor+gitlab+docker 搭建_第1张图片

进入容器,查看/var/jenkins_home/secrets/initialAdminPassword文件获取密码


docker exec -it 容器ID /bin/bash

vim /var/jenkins_home/secrets/initialAdminPassword

你可能感兴趣的:(docker,ci/cd,jenkins,gitlab,容器)