文章目录
- 拉取 jenkins 镜像
- 排查问题
- 验证结果
- 总结
拉取 jenkins 镜像
在官方镜像仓库查询 jenkins 镜像
https://hub.docker.com/r/jenkins/jenkins
拉取镜像
docker pull jenkins/jenkins
结果如下:
zhao@sh-zhao ~ % docker pull jenkins/jenkins:latest
latest: Pulling from jenkins/jenkins
dc80b8cdbfd3: Pull complete
1fd6cbbf3dee: Pull complete
6215f3cd952f: Pull complete
e14feb424362: Pull complete
9182b3d95b04: Pull complete
841e11b2945e: Pull complete
509a83fa41e8: Pull complete
89dc3c2e5cf1: Pull complete
d1b2cca7ed3e: Pull complete
cc268a10fb20: Pull complete
b22c15c6dd9e: Pull complete
dd479dcfc7b5: Pull complete
e816ba0de8af: Pull complete
Digest: sha256:7560cc798140cdcdef5b75ca069c28b2a44f179827e3e55076ea18bdfb17b5aa
Status: Downloaded newer image for jenkins/jenkins:latest
docker.io/jenkins/jenkins:latest
在本地查看镜像
运行镜像,发现并没有正确运行 jenkins
排查问题
在镜像介绍的文档中,有一个连接,点进去看看。
发现是一个 github 地址
https://github.com/jenkinsci/docker/blob/master/README.md
通过阅读文档发现,原来 jenkisn 运行需要一个 jdk11 的镜像,并且给出了jdk 镜像下载办法。
docker run -p 8080:8080 -p 50000:50000 --restart=on-failure jenkins/jenkins:lts-jdk11
意思是:运行jenkins:lts-jdk11
镜像时, 宿主的端口 8080 映射到虚拟机的 50000 端口,--restart=on-failure
意思是在 docker 只有在非0状态退出时才重新启动容器;
运行结果:
zhao@sh-zhao ~ % docker run -p 8080:8080 -p 50000:50000 --restart=on-failure jenkins/jenkins:lts-jdk11
Unable to find image 'jenkins/jenkins:lts-jdk11' locally
lts-jdk11: Pulling from jenkins/jenkins
8022b074731d: Pull complete
b45b4f0ed0e2: Pull complete
c3046dd3ca81: Pull complete
02e31ab40a45: Pull complete
ea7acd286e3e: Pull complete
c71a21ea0759: Pull complete
2f8f809ea17a: Pull complete
e5687d0032b5: Pull complete
c9ab6b65d272: Pull complete
df7b970e61fe: Pull complete
81e4a256bcec: Pull complete
51cb82414871: Pull complete
fbfc81247dad: Pull complete
Digest: sha256:aacbb5797dd210cc048038d9d3e5ab5795ea018fad843ffc1888c547911819ce
Status: Downloaded newer image for jenkins/jenkins:lts-jdk11
Running from: /usr/share/jenkins/jenkins.war
webroot: /var/jenkins_home/war
2023-04-23 03:49:22.495+0000 [id=1] INFO winstone.Logger#logInternal: Beginning extraction from war file
2023-04-23 03:49:23.245+0000 [id=1] WARNING o.e.j.s.handler.ContextHandler#setContextPath: Empty contextPath
2023-04-23 03:49:23.283+0000 [id=1] INFO org.eclipse.jetty.server.Server#doStart: jetty-10.0.13; built: 2022-12-07T20:13:20.134Z; git: 1c2636ea05c0ca8de1ffd6ca7f3a98ac084c766d; jvm 11.0.18+10
2023-04-23 03:49:23.563+0000 [id=1] INFO o.e.j.w.StandardDescriptorProcessor#visitServlet: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
2023-04-23 03:49:23.608+0000 [id=1] INFO o.e.j.s.s.DefaultSessionIdManager#doStart: Session workerName=node0
2023-04-23 03:49:23.922+0000 [id=1] INFO hudson.WebAppMain#contextInitialized: Jenkins home directory: /var/jenkins_home found at: EnvVars.masterEnvVars.get("JENKINS_HOME")
2023-04-23 03:49:24.009+0000 [id=1] INFO o.e.j.s.handler.ContextHandler#doStart: Started w.@4c18621b{Jenkins v2.387.2,/,file:///var/jenkins_home/war/,AVAILABLE}{/var/jenkins_home/war}
2023-04-23 03:49:24.020+0000 [id=1] INFO o.e.j.server.AbstractConnector#doStart: Started ServerConnector@3f390d63{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2023-04-23 03:49:24.027+0000 [id=1] INFO org.eclipse.jetty.server.Server#doStart: Started Server@66b7550d{STARTING}[10.0.13,sto=0] @1991ms
2023-04-23 03:49:24.030+0000 [id=24] INFO winstone.Logger#logInternal: Winstone Servlet Engine running: controlPort=disabled
2023-04-23 03:49:24.162+0000 [id=31] INFO jenkins.InitReactorRunner$1#onAttained: Started initialization
2023-04-23 03:49:24.178+0000 [id=30] INFO jenkins.InitReactorRunner$1#onAttained: Listed all plugins
2023-04-23 03:49:24.549+0000 [id=35] INFO jenkins.InitReactorRunner$1#onAttained: Prepared all plugins
2023-04-23 03:49:24.552+0000 [id=30] INFO jenkins.InitReactorRunner$1#onAttained: Started all plugins
2023-04-23 03:49:24.556+0000 [id=34] INFO jenkins.InitReactorRunner$1#onAttained: Augmented all extensions
2023-04-23 03:49:24.645+0000 [id=29] INFO jenkins.InitReactorRunner$1#onAttained: System config loaded
2023-04-23 03:49:24.646+0000 [id=36] INFO jenkins.InitReactorRunner$1#onAttained: System config adapted
2023-04-23 03:49:24.646+0000 [id=36] INFO jenkins.InitReactorRunner$1#onAttained: Loaded all jobs
2023-04-23 03:49:24.647+0000 [id=36] INFO jenkins.InitReactorRunner$1#onAttained: Configuration for all jobs updated
2023-04-23 03:49:24.697+0000 [id=49] INFO hudson.util.Retrier#start: Attempt #1 to do the action check updates server
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/var/jenkins_home/war/WEB-INF/lib/groovy-all-2.4.21.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2023-04-23 03:49:24.942+0000 [id=30] INFO jenkins.install.SetupWizard#init:
*************************************************************
*************************************************************
*************************************************************
Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:
47b1eb28fe4146da964bff4caa31b14d
This may also be found at: /var/jenkins_home/secrets/initialAdminPassword
到这里 jenkins 依赖的 jdk11 容器已经安装完成了。
验证结果
分别启动 jkd11 、jenkins 镜像
访问:http://localhost:8080/
总结
事实上,jenkins image 主页已经清楚的写明
This is a fully functional Jenkins server, based on the weekly and LTS releases .
一个功能齐全的Jenkins服务器,基于每周发布的版本和长期维护的版本(LTS)版本
。
LTS 意思是 Long Time Support
,长期支持的意思,LTS版本为稳定版,非LTS版本为测试版。
遇到问题,多看文档,多看文档,多看文档。