背景
在安装JenKins插件的时候,看到Jenkins提醒有版本可以升级,于是就点击了一下,结果重启Jenkins失败,日志提醒需要依赖 Java 11 ,但是镜像中的java版本是8,因此一致报错,解决方案将 jenkins.war 还原到之前的版本
解决思路
1. Jenkins启动失败查日志
docker logs -f 6374eb184a3a --tail=100
-> See https://jenkins.io/redirect/java-support/ for more information.
Running with Java 8 from /opt/java/openjdk/jre, which is older than the minimum required version (Java 11).
Supported Java versions are: [11, 17, 21]
See https://jenkins.io/redirect/java-support/ for more information.
Running with Java 8 from /opt/java/openjdk/jre, which is older than the minimum required version (Java 11).
Supported Java versions are: [11, 17, 21]
2. 找到容器中的的安装目录
docker inspect 6374eb184a3a |grep UpperDir
3. 进入容器在宿主机的文件夹
cd /data1/docker/overlay2/2e768d34624ed803c76d38488908589ce29fb563817809ee6c06962372f6b734/diff
# 查询war包的位置
find -name jenkins.war
-> ./usr/share/jenkins/jenkins.war
# 进入jenkins目录
cd ./usr/share/jenkins/
# 将当前的war包改个名字
mv jenkins.war jenkins.war_20240313 备份新版本
mv mv jenkins.war.bak jenkins.war 将之前的版本还原回来
4. 重新启动镜像
docker restart jenkins
5. 稍等片刻,Jenkins就可以访问了
当然也可以尝试替换一下 替换一下openjdk试试,文件路径 cd ./opt/java/openjdk/
参考: https://www.cnblogs.com/rirakkuma/articles/17679944.html