How to Install Jenkins using Docker | Step by step guide | scmGalaxy

jenkins-installation-using-docker
Step 1: Installing Docker

[code]
$ apt-get install docker (Ubuntu)
$ yum install docker  (RHEL/CENTOS)
[/code]

Step 2:  First, pull the official jenkins image from Docker repository.

[code]$ docker pull jenkins [/code]

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.

[code]$ docker run -d -p 8080:8080 -p 50000:50000 jenkins [/code]

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.

[code]$ docker run -d -p 8080:8080 -p 50000:50000 -u root -v $PWD/jenkins:/var/jenkins_home jenkins [/code]

 Other Example:

[code]docker run -d -p 49001:8080 -v $PWD/jenkins:/var/jenkins_home -t jenkins -u root [/code]

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:

[code]
$ mkdir jenkins
$ chown 1000 jenkins
$ docker run -d -p 49001:8080 -v $PWD/jenkins:/var/jenkins_home -t jenkins
[/code]

How to see the Jenkins log?

[code]$ docker exec name tail -f /var/log/jenkins/jenkins.log
Where name = –name [/code]

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.
Rajesh Kumar
Follow me
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x