简体   繁体   中英

Docker jenkins container is stuck while running

I can't run a jenkins image with docker. It is getting stuck while running:

afik@ubuntu:~$ docker run --name myjenkins -p 8080:8080 -p 50000:50000 -v /var/jenkins_home jenkins > out1 Aug 23, 2018 10:34:41 AM Main deleteWinstoneTempContents WARNING: Failed to delete the temporary Winstone file /tmp/winstone/jenkins.war Aug 23, 2018 10:34:41 AM org.eclipse.jetty.util.log.JavaUtilLog info INFO: Logging initialized @422ms Aug 23, 2018 10:34:41 AM winstone.Logger logInternal INFO: Beginning extraction from war file Aug 23, 2018 10:34:42 AM org.eclipse.jetty.util.log.JavaUtilLog warn WARNING: Empty contextPath Aug 23, 2018 10:34:42 AM org.eclipse.jetty.util.log.JavaUtilLog info INFO: jetty-9.2.z-SNAPSHOT Aug 23, 2018 10:34:42 AM org.eclipse.jetty.util.log.JavaUtilLog info INFO: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet Aug 23, 2018 10:34:43 AM org.eclipse.jetty.util.log.JavaUtilLog info INFO: Started w.@47404bea{/,file:/var/jenkins_home/war/,AVAILABLE}{/var/jenkins_home/war} Aug 23, 2018 10:34:43 AM org.eclipse.jetty.util.log.JavaUtilL og info INFO: Started ServerConnector@1252b961{HTTP/1.1}{0.0.0.0:8080} Aug 23, 2018 10:34:43 AM org.eclipse.jetty.util.log.JavaUtilLog info INFO: Started @2442ms Aug 23, 2018 10:34:43 AM winstone.Logger logInternal INFO: Winstone Servlet Engine v2.0 running: controlPort=disabled Aug 23, 2018 10:34:43 AM jenkins.InitReactorRunner$1 onAttained INFO: Started initialization Aug 23, 2018 10:34:43 AM jenkins.InitReactorRunner$1 onAttained INFO: Listed all plugins Aug 23, 2018 10:34:44 AM jenkins.InitReactorRunner$1 onAttained INFO: Prepared all plugins Aug 23, 2018 10:34:44 AM jenkins.InitReactorRunner$1 onAttained INFO: Started all plugins Aug 23, 2018 10:34:44 AM jenkins.InitReactorRunner$1 onAttained INFO: Augmented all extensions Aug 23, 2018 10:34:44 AM jenkins.InitReactorRunner$1 onAttained INFO: Loaded all jobs Aug 23, 2018 10:34:45 AM hudson.model.AsyncPeriodicWork$1 run INFO: Started Download metadata Aug 23, 2018 10:34:45 AM jenkins.util.groovy.GroovyHookScript execute INFO: Execut ing /var/jenkins_home/init.groovy.d/tcp-slave-agent-port.groovy Aug 23, 2018 10:34:45 AM jenkins.InitReactorRunner$1 onAttained INFO: Completed initialization Aug 23, 2018 10:34:45 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh INFO: Refreshing org.springframework.web.context.support.StaticWebApplicationContext@7147f78f: display name [Root WebApplicationContext]; startup date [Thu Aug 23 10:34:45 UTC 2018]; root of context hierarchy Aug 23, 2018 10:34:45 AM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory INFO: Bean factory for application context [org.springframework.web.context.support.StaticWebApplicationContext@7147f78f]: org.springframework.beans.factory.support.DefaultListableBeanFactory@6dbf29b1 Aug 23, 2018 10:34:45 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@6dbf29b1: defining beans [authenticationManager]; root of factory hierarchy Aug 23, 2018 10:34:45 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh INFO: Refreshing org.springframework.web.context.support.StaticWebApplicationContext@74caac54: display name [Root WebApplicationContext]; startup date [Thu Aug 23 10:34:45 UTC 2018]; root of context hierarchy Aug 23, 2018 10:34:45 AM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory INFO: Bean factory for application context [org.springframework.web.context.support.StaticWebApplicationContext@74caac54]: org.springframework.beans.factory.support.DefaultListableBeanFactory@4e956477 Aug 23, 2018 10:34:45 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@4e956477: defining beans [filter,legacy]; root of factory hierarchy Aug 23, 2018 10:34:45 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: ac6f4e5afd7c4a7f8ee2d360b3c5649d This may also be found at: /var/jenkins_home/secrets/initialAdminPassword ************************************************************* ************************************************************* ************************************************************* Aug 23, 2018 10:34:50 AM hudson.model.UpdateSite updateData INFO: Obtained the latest update center data file for UpdateSource default Aug 23, 2018 10:34:51 AM hudson.WebAppMain$3 run INFO: Jenkins is fully up and running Aug 23, 2018 10:34:51 AM hudson.model.UpdateSite updateData INFO: Obtained the latest update center data file for UpdateSource default Aug 23, 2018 10:34:53 AM hudson.model.DownloadService$Downloadable load INFO: Obtained the updated data file for hudson.tasks.Maven.MavenInstaller Aug 23, 2018 10:34:54 AM hudson.model.DownloadService$Downloadable load INFO: Obtained the updated data file for hudson.tools.JDKInstaller Au g 23, 2018 10:34:54 AM hudson.model.AsyncPeriodicWork$1 run INFO: Finished Download metadata. 9,318 ms ^CAug 23, 2018 10:36:00 AM winstone.Logger logInternal INFO: JVM is terminating. Shutting down Winstone afik@ubuntu:~$

You actually are running Jenkins... you're just doing it "interactively." That is, you're attached to the process that the docker run command kicked off. If you look at the Dockerfile for the Jenkins image, you'll see:

ENTRYPOINT ["/bin/tini", "--", "/usr/local/bin/jenkins.sh"]

This basically says that, when you run a Jenkins container, it will kick off that shell script. When you get to the point of seeing this:

INFO: Finished Download metadata. 9,318 ms

You're Jenkins container is up and running. You should be able to open a browser and point it to http://localhost:8080/ , where you should see the Jenkins UI.

In order to not have your terminal window sit on the command like that, you need to instruct docker to detach from the container (sort of like running a process in the background). If you run docker run --help , you'll see the following entry:

-d, --detach        Run container in background and print container ID

So you just need to use the -d flag in your command:

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

Instead of showing you the logs, it will instead display a container ID (a big long alphanumeric). Now, if you want to see the logs (for instance, to get the Jenkins-generated password), you can use:

docker logs myjenkins

(that's the name you assigned to the container with the --name option) or

docker logs [container ID]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM