因为jenkins/jenkins镜像默认带的jenkins版本比较低,导致安装完以后,很多插件因为版本问题无法安装。以下是最权威,最方便的安装教程。
1. 创建本地挂载目录
mkdir -p /mnt/dockerdata/jenkins/home/
2. 修改挂载目录权限
chown -R 1000:1000 /mnt/dockerdata/jenkins/home
3. 下载jenkins镜像
docker pull jenkins/jenkins
4. 启动jenkins服务
docker run -d \
-p 8887:8080 \
-p 50000:50000 \
-v /mnt/dockerdata/jenkins/home:/var/jenkins_home \
-v /etc/localtime:/etc/localtime \
--name jenkins jenkins/jenkins
5. 下载最新版的jenkins java war包
https://www.jenkins.io/download/
6. 将这个jar包上传到服务器jenkins的挂载目录 /mnt/dockerdata/jenkins/home/
7. 进入jenkins容器内部
docker exec -it -u root jenkins bash
8. 替换容器内最新版的jenkins war包
cd /usr/share/jenkins
cp jenkins.war jenkinsBAK.war
cp /var/jenkins_home/jenkins.war /usr/share/jenkins/
exit
9. 重启jenkins
docker restart jenkins