提前安装好jdk和maven,jdk最好使用11版本,jdk-11.0.10
docker run -u root -d \
-p 100:8080 \
-v /var/jenkins_home/workspace/:/var/jenkins_home/workspace/ \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/bin/docker:/usr/bin/docker \
-v /usr/local/java/jdk1.8.0_241:/usr/local/java \
-v /usr/local/apache-maven-3.9.1:/usr/local/maven \
-e JAVA_OPTS="-Dorg.apache.commons.jelly.tags.fmt.timeZone='Asia/Shanghai" \
--name myjenkins jenkins/jenkins:2.401
参考:
使用Docker安装部署Jenkins_docker部署jenkins-CSDN博客
流水线编写示例:Jenkins把GitHub项目做成Docker镜像_ITPUB博客