本实践介绍了利用Jenkins和docker技术,如何实现CI/CD的各环节的步骤,包括环境准备,代码提交,编译程序,构建镜像,部署一套完整的安装部署流程。
工具介绍:
操作系统centos 7.3 关闭防火墙 ,selinux
我是虚拟机装的Centos7,linux 3.10 内核,docker官方说至少3.8以上,建议3.10以上
root账户登录,查看内核版本如下:
[root@word-test ~]# uname -a
Linux word-test.com 3.10.0-1127.el7.x86_64 #1 SMP Tue Mar 31 23:36:51 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
进入docker官网在installation per distro 下的install on centos
删除旧版本:
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
需要的安装包
yum install -y yum-utils
设置镜像仓库
yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
如果缺包就执行以下命令,然后在执行上面那条命令:
wget -O /etc/yum.repos.d/CentOS-Base.repo \
http://mirrors.aliyun.com/repo/Centos-7.repo
更新yum 软件包索引
yum makecache fast**
安装docker docker -ce社区版 ee 企业版
yum install docker-ce docker-ce-cli containerd.io
安装完成后,启动docker
[root@word-test ~]# systemctl start docker.service
[root@word-test ~]# systemctl status docker.service
使用docker version 查看是否安装成功:
Client: Docker Engine - Community
Version: 20.10.14
API version: 1.41
Go version: go1.16.15
Git commit: a224086
Built: Thu Mar 24 01:49:57 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.14
API version: 1.41 (minimum version 1.12)
Go version: go1.16.15
Git commit: 87a90dc
Built: Thu Mar 24 01:48:24 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.5.11
GitCommit: 3df54a852345ae127d1fa3092b95168e4a88e2f8
runc:
Version: 1.0.3
GitCommit: v1.0.3-0-gf46b6ba
docker-init:
Version: 0.19