先删除系统docker相关的依赖
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
安装docker相关依赖
yum install -y yum-utils
配置docker镜像地址
yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y docker-ce-20.10.7 docker-ce-cli-20.10.7 containerd.io-1.4.6
创建docker目录,并配置
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://w6rlizew.mirror.aliyuncs.com"],
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
启动和关闭docker命令:
systemctl start docker
systemctl enable docker
修改主机名,关闭和启动防火墙
hostnamectl set-hostname k8s-master && bash #修改主机名
systemctl stop firewalld
systemctl disable firewalld
配置JDK和Maven
cd /etc/profile
export JAVA_HOME=/usr/local/jdk1.8.0_371
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export MAVEN_HOME=/usr/local/maven/apache-maven-3.6.3
export PATH=${MAVEN_HOME}/bin:${JAVA_PATH}:${PATH}
## 执行命令
source /etc/profile
使用docker操作jenkins
docker start jenkins ## 开启jenkins
docker stop jenkins ## 停止jenkins
docker rm jenkins ## 删除jenkins镜像
## 运行jenkins
docker run -d -uroot -p 8080:8080 -p 50000:50000 -p 8888:8888 --name jenkins -v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):/usr/bin/docker -v /data/jenkins/jenkins:/var/jenkins -v /data/jenkins/jenkins_home:/var/jenkins_home -v /etc/localtime:/etc/localtime -v /usr/local/jdk-11.0.19:/usr/local/jdk-11.0.19 -v /usr/local/maven/apache-maven-3.6.3:/usr/local/maven/apache-maven-3.6.3 -v /etc/profile:/etc/profile jenkins/jenkins