docker部署jenkins
建议使⽤的Docker映像是jenkinsci/blueocean image(来⾃ the Docker Hub repository)。该镜像包含当前的长期⽀持 (LTS) 的Jenkins版本(可以投⼊使⽤),捆绑了所有Blue Ocean插件和功能。
部署⽅法:
docker run \
-u root \
--name jenkins \
-d \
-p 8080:8080 \
-p 50000:50000 \
-v jenkins-data:/var/jenkins_home \
-v /var/run/docker.sock:/var/run/docker.sock \
jenkinsci/blueocean
参数说明:
--name jenkins (可选)指定容器名称
-d (可选)jenkinsci/blueocean 在后台运⾏容器(即“分离”模式)并输出容器ID。如果您不指定此选项,则在终端窗⼝中输出正在运⾏的此容器的Docker⽇志。
-p 8080:8080 映射jenkinsci/blueocean 容器的端⼝8080到主机上的端⼝8080。第⼀个数字代表主机上的端⼝,⽽最后⼀个代表容器的端⼝。如果您为此选项指定 -p 49000:8080 ,您将通过端⼝49000访问主机上的Jenkins。
-p 50000:50000 可选)将 jenkinsci/blueocean 容器的端⼝50000 映射到主机上的端⼝50000。如果您在其他机器上设置了⼀个或多个基于JNLP的Jenkins代理程序,⽽这些代理程序⼜与 jenkinsci/blueocean 容器交互(充当“主”Jenkins服务器,或者简称为“Jenkins主”),则这是必需的。默认情况下,基于JNLP的Jenkins代理通过TCP端⼝50000与Jenkins主站进⾏通信。
-v jenkins-data:/var/jenkins_home (可选,但强烈建议)映射在容器中的`/var/jenkins_home` ⽬录到具有名字 jenkins-data 的volume。如果这个卷不存在,那么这个docker run 命令会⾃动为你创建卷。
如果您希望每次重新启动Jenkins(通过此 docker run ... 命令)时保持Jenkins状态,则此选项是必需的。
-v /var/run/docker.sock:/var/run/docker.sock (可选 /var/run/docker.sock 表⽰Docker守护程序通过其监听的基于Unix的套接字。该映射允许 jenkinsci/blueocean 容器与Docker守护进程通信,如果 jenkinsci/blueocean 容器需要实例化其他Docker容器,则该守护进程是必需的。
jenkinsci/blueocean jenkinsci/blueocean Docker镜像本⾝。如果此镜像尚未下载,则此 docker run 命令将⾃动为您下载镜像。此外,如果⾃上次运⾏此命令后发布了此镜像的任何更新,则再次运⾏此命令将⾃动为您下载这些已发布的镜像更新。注意:这个Docker镜像也可以使⽤以下 docker pull命令独⽴下载(或更新): docker pull jenkinsci/blueocean
此安装⽅法取⾃jenkins官⽅安装⽂档。
配置实例:
[root@localhost ~]# docker run \
> -u root \
> --name jenkins \
> -d \
> -p 8080:8080 \
> -p 50000:50000 \
> -v jenkins-data:/var/jenkins_home \
> -v /var/run/docker.sock:/var/run/docker.sock \
> jenkinsci/blueocean
Unable to find image 'jenkinsci/blueocean:latest' locally
latest: Pulling from jenkinsci/blueocean
bdf0201b3a05: Pull complete
9e12771959ad: Pull complete
018b76c3c533: Pull complete
fb7916dfb471: Pull complete
efeeaeb1034e: Pull complete
9d0828dae329: Pull complete
93c94dc28c28: Pull complete
51c9f4cab046: Pull complete
1529253d9fb0: Pull complete
0308c8ef7639: Pull complete
e701e5d6451c: Pull complete
3a0b79c07d56: Pull complete
28c17bce8836: Pull complete
d1e02b0dadf5: Pull complete
2a22db2a9af0: Pull complete
Digest: sha256:6cb529ad8c56539e4480a567a1b86a1926fa667de55db6fb4e795e13af6509f7
Status: Downloaded newer image for jenkinsci/blueocean:latest
1ac2c92cf7b2b4c58cab5c17046683da6be5781ba31b6c7b9533f24c0f89b190
打开web管理页⾯:
密码可以从docker logs 中查到:
[root@localhost ~]# docker logs jenkins
Running from: /usr/share/jenkins/jenkins.war
webroot: ("JENKINS_HOME")
May 22, 20192:36:57 lipse.jetty.util.log.Log initialized
INFO: Logging initialized @485ms lipse.jetty.util.log.JavaUtilLog
May 22, 20192:36:57 AM winstone.Logger logInternal
INFO: Beginning extraction from war file
May 22, 20192:36:59 lipse.jetty.server.handler.ContextHandler setContextPath
WARNING: Empty contextPath
May 22, 20192:36:59 lipse.jetty.server.Server doStart
INFO: jetty-9.4.z-SNAPSHOT; built: 2018-08-30T13:59:14.071Z; git: 27208684755d94a92186989f695db2d7b21ebc51; jvm 1.8.0_212-b04
May 22, 20192:36:59 lipse.jetty.webapp.StandardDescriptorProcessor visitServlet
INFO: NO JSP Support for /, did not lipse.jetty.jsp.JettyJspServlet
May 22, 20192:36:59 lipse.jetty.server.session.DefaultSessionIdManager doStart
INFO: DefaultSessionIdManager workerName=node0
May 22, 20192:36:59 lipse.jetty.server.session.DefaultSessionIdManager doStart
INFO: No SessionScavenger set, using defaults
May 22, 20192:36:59 lipse.jetty.server.session.HouseKeeper startScavenging
INFO: node0 Scavenging every 660000ms
Jenkins home directory: /var/jenkins_home found at: ("JENKINS_HOME")
May 22, 20192:37:00 lipse.jetty.server.handler.ContextHandler doStart
INFO: Started w.@7689ddef{Jenkins v2.164.3,/,file:///var/jenkins_home/war/,AVAILABLE}{/var/jenkins_home/war}
May 22, 20192:37:00 lipse.jetty.server.AbstractConnector doStart
INFO: Started ServerConnector@1df98368{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
May 22, 20192:37:00 lipse.jetty.server.Server doStart
INFO: Started @3346ms
May 22, 20192:37:00 AM winstone.Logger logInternal
INFO: Winstone Servlet Engine v4.0 running: controlPort=disabled
May 22, 20192:37:01 AM jenkins.InitReactorRunner$1 onAttained
INFO: Started initialization
May 22, 20192:37:03 AM jenkins.InitReactorRunner$1 onAttained
INFO: Listed all plugins
May 22, 20192:37:10 AM jenkins.InitReactorRunner$1 onAttained
INFO: Prepared all plugins
May 22, 20192:37:10 AM jenkins.InitReactorRunner$1 onAttained
reactor springINFO: Started all plugins
May 22, 20192:37:12 AM jenkins.InitReactorRunner$1 onAttained
INFO: Augmented all extensions
May 22, 20192:37:12 AM jenkins.InitReactorRunner$1 onAttained
INFO: Loaded all jobs
May 22, 20192:37:12 del.AsyncPeriodicWork$1 run
INFO: Started Download metadata
May 22, 20192:37:12 AM hudson.util.Retrier start
INFO: Attempt #1 to do the action check updates server
May 22, 20192:37:13 AM t.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.t.support.StaticWebApplicationContext@47fafdbc: display name [Root WebApplicationContext]; startup date [Wed May 2202:37:13 GMT 2019]; root of context hierarchy May 22, 20192:37:13 AM t.support.AbstractApplicationContext obtainFreshBeanFactory
INFO: Bean factory for application context [org.t.support.StaticWebApplicationContext@47fafdbc]: org.springframework.beans.factory.support.DefaultListableBeanFactory@4bc62933
May 22, 20192:37:13 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@4bc62933: defining beans [authenticationManager]; root of factory hierarchy
May 22, 20192:37:13 AM t.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.t.support.StaticWebApplicationContext@4c2b95b7: display name [Root WebApplicationContext]; startup date [Wed May 2202:37:13 GMT 2019]; root of context hierarchy May 22, 20192:37:13 AM t.support.AbstractApplicationContext obtainFreshBeanFactory
INFO: Bean factory for application context [org.t.support.StaticWebApplicationContext@4c2b95b7]: org.springframework.beans.factory.support.DefaultListableBeanFactory@630931a0
May 22, 20192:37:13 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@630931a0: defining beans [filter,legacy]; root of factory hierarchy
May 22, 20192:37:13 AM jenkins.install.SetupWizard init
INFO:
*************************************************************
*************************************************************
*************************************************************
Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:
afc3cd17d54d40379d9c880d21af457d
This may also be found at: /var/jenkins_home/secrets/initialAdminPassword
*************************************************************
*************************************************************
*************************************************************
May 22, 20192:37:24 del.UpdateSite updateData
INFO: Obtained the latest update center data file for UpdateSource default
May 22, 20192:37:25 del.DownloadService$Downloadable load
INFO: Obtained the updated data file for hudson.tasks.Maven.MavenInstaller May 22, 20192:37:25 AM hudson.util.Retrier start
INFO: Performed the action check updates server successfully at the attempt #1 May 22, 20192:37:25 del.AsyncPeriodicWork$1 run
INFO: Finished Download metadata. 12,955 ms
May 22, 20192:37:26 del.UpdateSite updateData
INFO: Obtained the latest update center data file for UpdateSource default
May 22, 20192:37:26 AM jenkins.InitReactorRunner$1 onAttained
INFO: Completed initialization
May 22, 20192:37:26 AM hudson.WebAppMain$3 run
INFO: Jenkins is fully up and running
将密码粘贴后,点击确定,到⼀下⼀个页⾯:
在下个页⾯中可以选择插件,并安装:
开始安装:
安装完成后输⼊必要的配置信息,界⾯如下:
到此,安装完成。界⾯如下:
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论