一、Jenkins介绍
Jenkins是一个开源软件项目,起源于Hudson(Hudson是商用的),是基于Java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开放易用的软件平台,使软件项目可以进行持续集成。
二、docker-compose安装
Linux上我们可以从Github上下载它的二进制包来使用,最新发行的版本地址:https://github.com/docker/compose/releases。
1、运行以下命令以下载Docker Compose的v2.11.0版本
[root@k8s-master ~]# wget -O /usr/bin/docker-compose https://github.com/docker/compose/releases/download/v2.11.0/docker-compose-linux-x86_64
2、授权可执行权限
[root@k8s-master ~]# chmod +x /usr/bin/docker-compose
3、测试是否安装成功
[root@k8s-master ~]# docker-compose -v
Docker Compose version v2.11.0
三、Docker安装
Docker支持以下的64位CentOS版本:
- CentOS 7
- CentOS 8
- 更高版本...
1)使用官方安装脚本自动安装
安装命令如下:
[root@localhost ~]# curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
也可以使用国内daocloud一键安装命令:
[root@localhost ~]# curl -sSL https://get.daocloud.io/docker | sh
2)使用阿里云源安装
[root@localhost ~]# yum -y install yum-utils device-mapper-persistent-data lvm2
[root@localhost ~]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@localhost ~]# yum -y install docker-ce docker-ce-cli containerd.io
3)配置镜像加速器
[root@localhost ~]# mkdir -p /etc/docker
[root@localhost ~]# vim /etc/docker/daemon.json
# 添加以下内容
{
"registry-mirrors": [
"https://hub-mirror.c.163.com",
"https://reg-mirror.qiniu.com",
"https://cr.console.aliyun.com",
"https://docker.mirrors.ustc.edu.cn"
]
}
4)启动Docker
[root@localhost ~]# systemctl enable docker
[root@localhost ~]# systemctl start docker
四、Jenkins安装
1)拉取Jenkins镜像
# 查询Jenkins镜像
[root@localhost ~]# docker search jenkins
[root@localhost ~]# docker pull jenkins/jenkins:lts
lts: Pulling from jenkins/jenkins
34df401c391c: Pull complete
0a9fd8e53c6a: Pull complete
391e27ed62a1: Pull complete
68537fbf33f7: Pull complete
df6bb788e02d: Pull complete
c9125b38315d: Pull complete
f1260ad0128a: Pull complete
d3bdc68f4f05: Pull complete
a92b2c570148: Pull complete
3796b61e99d2: Pull complete
a554f110ec9b: Pull complete
f0fa1508981d: Pull complete
d23784115f48: Pull complete
Digest: sha256:1638b593a6a86649c1c9f18d62dc8f233122bb1f7518ec525b34029804b404dc
Status: Downloaded newer image for jenkins/jenkins:lts
docker.io/jenkins/jenkins:lts
2)创建Jenkins数据持久化目录
[root@localhost ~]# mkdir -p /data/jenkins
3)编写docker-compose.yml
[root@localhost ~]# mkdir -p /opt/jenkins
[root@localhost ~]# vim /opt/jenkins/docker-compose.yml
version: '3.3'
services:
jenkins:
user: root
restart: always
image: jenkins/jenkins:lts
container_name: jenkins
ports:
- 8080:8080
- 50000:50000
volumes:
- /data/jenkins:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
- /usr/bin/docker:/usr/bin/docker
- /usr/local/bin/docker-compose:/usr/local/bin/docker-compose
4)启动Jenkins
[root@localhost ~]# docker-compose -f /opt/jenkins/docker-compose.yml up -d
5)查看Jenkins运行情况
[root@localhost ~]# docker-compose -f /opt/jenkins/docker-compose.yml ps -a
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
jenkins jenkins/jenkins:lts "/usr/bin/tini -- /u…" jenkins About a minute ago Up About a minute 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp, 0.0.0.0:50000->50000/tcp, :::50000->50000/tcp
五、Jenkins使用
1)访问Jenkins
# 浏览器输入http://192.168.36.198:8080,如下图所示
2)密码查看方式
[root@localhost ~]# cat /data/jenkins/secrets/initialAdminPassword
0803aa850a39414f9171807f8d52c419
3)选择推荐插件
4)使用默认admin用户
5)配置Jenkins URL
6)修改admin密码
若文章图片、下载链接等信息出错,请在评论区留言反馈,博主将第一时间更新!如本文“对您有用”,欢迎随意打赏,谢谢!
评论