July 27, 2020

[Note] Jenkins in Docker

I used to run Jenkins on a personal server, run it only when it's needed -- not only the server computer itself, but Jenkins process as well, to save electricity and memory on that server.  With docker, I can just run it on my Ubuntu desktop.  This makes everything easier and simpler.

https://hub.docker.com/_/jenkins/

Pull image


$ docker pull jenkins/jenkins

Do not get this image, it's deprecated and won't work properly -- $ docker pull jenkins
See, https://www.jenkins.io/blog/2018/12/10/the-official-Docker-image/


Run the container


8080, 8090 are used on my system, so I'm mapping to 8100 instead:

$ docker run --name jenkins -p 8100:8080 -p 50000:50000 -d jenkins/jenkins

Do below as soon as you run the container as above.  Then you'll see admin password in the log,

$ docker logs -f jenkins


Configure it


Open browser, http://localhost:8100

It'll ask for password stored in the conainer fils system.  Enter the password from the above log.  If you missed it, then log onto the container and retrieve it,

$ docker exec -it jenkins bash

In the container,
$ more /var/jenkins_home/secrets/initialAdminPassword

Copy & paste the password on the web page.  Then install plugins and set up a user.

Docker makes everything so simple and sweet!


No comments: