docker+jenkins+打包jdk8+Dockerfile

docker当前下载的jenkins镜像是默认jdk11

网上搜了一堆帖子
执行过程
docker 下载安装jenkins
docker run -d -p 8081:8080 -p 50001:50000
-v /usr/local/jenkins_home:/var/jenkins_home
-v /usr/local/jdk1.8.0_361:/var/jdk8
-v /usr/local/apache-maven-3.8.8:/var/maven
-v /var/run/docker.sock:/var/run/docker.sock
-v /etc/localtime:/etc/localtime
-v /usr/local/jenkins_home/profile:/etc/profile
--name jenkins --privileged=true jenkinsci/blueocean

配置 系统配置、全局工具配置


最后结果:/usr/local/apache-maven-3.8.8/bin/mvn: exec: line 194: /usr/local/jdk1.8.0_361/bin/java: not found

后来又看了一些帖子说 jenkins中的jdk 需要和 打包jdk一致。
如:
https://blog.csdn.net/w13511069150/article/details/125634457
https://blog.csdn.net/white_grimreaper/article/details/108282472
后来不纠结了 直接使用这个镜像试下
docker pull jenkins/jenkins:latest-jdk8

docker run -itd -p 8080:8080 -p 50000:50000 --name jenkins --privileged=true -v /var/jenkins_home:/var/jenkins_home -v /usr/local/apache-maven-3.8.8:/usr/local/apache-maven-3.8.8 -v /opt/repository:/opt/repository -v /var/run/docker.sock:/var/run/docker.sock jenkins/jenkins:latest-jdk8

docker exec -it fa62fd665e8b bash

配置上jdk8
chown -R 1000:1000 /opt/repository
chown -R 1000:1000 /var/jenkins_home

Dockerfile参见
https://mp.weixin.qq.com/s/jJk5m8Wlk5TpsBF0aRzIMw

posted @ 2023-06-29 19:05  倔强的老铁  阅读(972)  评论(0编辑  收藏  举报