Sign In or Register
Not Registered Yet?

Join Now! It's FREE. Get full access and benefit from this site

Reset My password - Remind Me My username

Remember me

Install Jenkins using Docker

Step 1: Installing Docker
# apt-get install docker (Ubuntu)
# yum install docker  (RHEL/CENTOS)
For more info, please following this http://www.scmgalaxy.com/scm/software-containers/how-to-install-docker-in-linux.html
Step 2:  First, pull the official jenkins image from Docker repository.
# docker pull jenkins
Step 3: Next, run a container using this image and map data directory from the container to the host; e.g in the example below /var/jenkins_home from the container is mapped to jenkins/ directory from the current path on the host. Jenkins 8080 port is also exposed to the host as 49001.

Mapping port 8080 on the host to the container (the web ui), port 50000 to port 50000 (for build agents). Run with `-p 50000:50000` so you can connect JNLP slaves. For port 50000. This is to handle connections from JNLP based build slaves. This will store the workspace in /var/jenkins_home. All Jenkins data lives in there including plugins and configuration.

> docker run -d -p 8080:8080 -p 50000:50000 jenkins
This will store the jenkins data in /your/home on the host. Ensure that /your/home is accessible by the jenkins user in container (jenkins user - uid 1000) or use -u some_other_user parameter with docker run.
> docker run -d -p 8080:8080 -p 50000:50000 -u root -v $PWD/jenkins:/var/jenkins_home jenkins 
Other Example:
docker run -d -p 49001:8080 -v $PWD/jenkins:/var/jenkins_home -t jenkins -u root

This will store the jenkins data in /your/home on the host. Ensure that /your/home is accessible by the jenkins user in container (jenkins user - uid 1000) or use -u some_other_user parameter with docker run. This information is also found in the Dockerfile. So all you need to do is to ensure that the directory $PWD/jenkins is own by UID 1000:
> mkdir jenkins
> chown 1000 jenkins
> docker run -d -p 49001:8080 -v $PWD/jenkins:/var/jenkins_home -t jenkins
How to see the Jenkins log?
> docker exec name tail -f /var/log/jenkins/jenkins.log
Where name = --name

Step 3:  Access to j=Jenkins
As we have successfully run Jenkins Container, we can browse Jenkins Web Interface using our Web Browser by pointint to http://ip-address:49001 or http://localhost:49001 according to the configuration.
Rate this item
(1 Vote)
Rajesh Kumar


Total, Over 12 years of extensive experience in the Software Configuration Management domain having depth knowledge of DevOps, Continuous Integration and Delivery, Configuration Management, Build and Installer, Release Management and Application Management.

What corporate management say about us?

Rajesh is very knowledgeable instructor he has a good exposure on real time issue and case studies he is experienced in large environment issue and challenges. I really liked how Rajesh used a lot of examples so that concepts were more easily understood, I like the examples that Rajesh give to help us remember things…they are usually real scenario, real life problems that we encounter frequently. <br /> He is well organised in terms of study materiel that you can refer anytime after you complete your course. His blogs are crisp and has to the point key content that he discussed during session to remember if you refer them remotely.

Gaurav Vishnoi
I am having 11+ years of experience in java, due to increasing complexity of system and environment I opted for this tanning and find it very useful., Noida
Sep 02, 2016