Install Jenkins in Docker Container

From Gejoreuy
Jump to navigation Jump to search


This page describes the process of installing and running a Jenkins instance inside a Docker container.


Make sure we already have Docker installed in the macine that we use t work.
In this document, we use Linux Oracle 7.7 as our experiment.
We can use another OS like Linux CentOS or Ubuntu, or also in Windows environement.

Step by Step

Create Jenkins home directory in the host machine.

 [root@gejoreuy ~]# mkdir /var/jenkins_home

Pull Jenkins image.

 [root@gejoreuy ~]# docker pull jenkins/jenkins:latest

Check the Jenkins image is ready.

 [root@komang-demotest-jenkins ~]# docker images
 REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
 jenkins/jenkins     latest              59f8784e08ee        42 hours ago        619MB

Run the Jenkins container.

 [root@komang-demotest-jenkins ~]# docker run -it -d --cap-add sys_admin --name jenkins-lts -p 8080:8080 -p 50000:50000 -v /var/run/docker.sock:/var/run/docker.sock -v /var/jenkins_home:/var/jenkins_home jenkins/jenkins:latest

Setup the Putty terminal tunnel to make Jenkins can be accessed through localhost port 8080 and 50000.
Then we can access Jenkins through http://localhost:8080
Or we also can access Jenkins to the host machine name or ip address trhough port 8080, like http://<ip_address>:8080


Create simple project :