docker的创建和登录疑问

1、jenkins:/var/jenkins_home 这一步是什么意思?虽然也执行成功了,但是执行前后/var下都没有看到jenkins_home目录。

···
docker run -d --name jenkins -p 8080:8080 -p 50000:50000 -v jenkins:/var/jenkins_home jenkins/jenkins:lts
····

2、使用docker logs jenkins打印出了log日志,但还是找不到密码

[root@192 jenkins_home]# docker logs jenkins
Running from: /usr/share/jenkins/jenkins.war
webroot: EnvVars.masterEnvVars.get("JENKINS_HOME")
2020-06-17 12:29:39.247+0000 [id=1]	INFO	org.eclipse.jetty.util.log.Log#initialized: Logging initialized @759ms to org.eclipse.jetty.util.log.JavaUtilLog
2020-06-17 12:29:39.471+0000 [id=1]	INFO	winstone.Logger#logInternal: Beginning extraction from war file
2020-06-17 12:29:39.535+0000 [id=1]	WARNING	o.e.j.s.handler.ContextHandler#setContextPath: Empty contextPath
2020-06-17 12:29:39.675+0000 [id=1]	INFO	org.eclipse.jetty.server.Server#doStart: jetty-9.4.27.v20200227; built: 2020-02-27T18:37:21.340Z; git: a304fd9f351f337e7c0e2a7c28878dd536149c6c; jvm 1.8.0_242-b08
2020-06-17 12:29:40.251+0000 [id=1]	INFO	o.e.j.w.StandardDescriptorProcessor#visitServlet: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
2020-06-17 12:29:40.342+0000 [id=1]	INFO	o.e.j.s.s.DefaultSessionIdManager#doStart: DefaultSessionIdManager workerName=node0
2020-06-17 12:29:40.343+0000 [id=1]	INFO	o.e.j.s.s.DefaultSessionIdManager#doStart: No SessionScavenger set, using defaults
2020-06-17 12:29:40.349+0000 [id=1]	INFO	o.e.j.server.session.HouseKeeper#startScavenging: node0 Scavenging every 600000ms
2020-06-17 12:29:41.151+0000 [id=1]	INFO	hudson.WebAppMain#contextInitialized: Jenkins home directory: /var/jenkins_home found at: EnvVars.masterEnvVars.get("JENKINS_HOME")
2020-06-17 12:29:41.372+0000 [id=1]	INFO	o.e.j.s.handler.ContextHandler#doStart: Started w.@147e2ae7{Jenkins v2.222.4,/,file:///var/jenkins_home/war/,AVAILABLE}{/var/jenkins_home/war}
2020-06-17 12:29:41.411+0000 [id=1]	INFO	o.e.j.server.AbstractConnector#doStart: Started ServerConnector@62043840{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2020-06-17 12:29:41.412+0000 [id=1]	INFO	org.eclipse.jetty.server.Server#doStart: Started @2925ms
2020-06-17 12:29:41.419+0000 [id=20]	INFO	winstone.Logger#logInternal: Winstone Servlet Engine running: controlPort=disabled
2020-06-17 12:29:43.437+0000 [id=27]	INFO	jenkins.InitReactorRunner$1#onAttained: Started initialization
2020-06-17 12:29:43.596+0000 [id=25]	INFO	jenkins.InitReactorRunner$1#onAttained: Listed all plugins
2020-06-17 12:29:46.310+0000 [id=27]	INFO	jenkins.InitReactorRunner$1#onAttained: Prepared all plugins
2020-06-17 12:29:46.322+0000 [id=27]	INFO	jenkins.InitReactorRunner$1#onAttained: Started all plugins
2020-06-17 12:29:46.383+0000 [id=25]	INFO	jenkins.InitReactorRunner$1#onAttained: Augmented all extensions
2020-06-17 12:29:47.085+0000 [id=28]	INFO	jenkins.InitReactorRunner$1#onAttained: System config loaded
2020-06-17 12:29:47.086+0000 [id=28]	INFO	jenkins.InitReactorRunner$1#onAttained: System config adapted
2020-06-17 12:29:47.086+0000 [id=28]	INFO	jenkins.InitReactorRunner$1#onAttained: Loaded all jobs
2020-06-17 12:29:47.088+0000 [id=26]	INFO	jenkins.InitReactorRunner$1#onAttained: Configuration for all jobs updated
2020-06-17 12:29:47.323+0000 [id=41]	INFO	hudson.model.AsyncPeriodicWork#lambda$doRun$0: Started Download metadata
2020-06-17 12:29:47.364+0000 [id=41]	INFO	hudson.model.AsyncPeriodicWork#lambda$doRun$0: Finished Download metadata. 12 ms
2020-06-17 12:29:48.721+0000 [id=28]	INFO	o.s.c.s.AbstractApplicationContext#prepareRefresh: Refreshing org.springframework.web.context.support.StaticWebApplicationContext@2548214f: display name [Root WebApplicationContext]; startup date [Wed Jun 17 12:29:48 UTC 2020]; root of context hierarchy
2020-06-17 12:29:48.721+0000 [id=28]	INFO	o.s.c.s.AbstractApplicationContext#obtainFreshBeanFactory: Bean factory for application context [org.springframework.web.context.support.StaticWebApplicationContext@2548214f]: org.springframework.beans.factory.support.DefaultListableBeanFactory@28ae576f
2020-06-17 12:29:48.744+0000 [id=28]	INFO	o.s.b.f.s.DefaultListableBeanFactory#preInstantiateSingletons: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@28ae576f: defining beans [authenticationManager]; root of factory hierarchy
2020-06-17 12:29:49.139+0000 [id=28]	INFO	o.s.c.s.AbstractApplicationContext#prepareRefresh: Refreshing org.springframework.web.context.support.StaticWebApplicationContext@1b9d71ea: display name [Root WebApplicationContext]; startup date [Wed Jun 17 12:29:49 UTC 2020]; root of context hierarchy
2020-06-17 12:29:49.139+0000 [id=28]	INFO	o.s.c.s.AbstractApplicationContext#obtainFreshBeanFactory: Bean factory for application context [org.springframework.web.context.support.StaticWebApplicationContext@1b9d71ea]: org.springframework.beans.factory.support.DefaultListableBeanFactory@5c338b9d
2020-06-17 12:29:49.140+0000 [id=28]	INFO	o.s.b.f.s.DefaultListableBeanFactory#preInstantiateSingletons: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@5c338b9d: defining beans [filter,legacy]; root of factory hierarchy
2020-06-17 12:29:49.256+0000 [id=28]	INFO	jenkins.InitReactorRunner$1#onAttained: Completed initialization
2020-06-17 12:29:49.485+0000 [id=19]	INFO	hudson.WebAppMain$3#run: Jenkins is fully up and running


你先进入容器,docker exec -it jenkins /bin/bash
然后cat /var/jenkins_home/secrets/initialAdminPassword 能找到初始的密码

1 Like

-v 是挂载目录,冒号前面的是宿主机目录,冒号后面的是容器里的目录,因为你宿主机目录用的不是一个本地路径,所以docker在volume里建立了一个对应名称的目录来进行管理

2 Likes