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

Step 1: Installing Docker
$ apt-get install docker (Ubuntu)
$ yum install docker  (RHEL/CENTOS)
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.
Tagged : / / / / / / / / / / / / /

Complete Linux & Shell Scripting Guide and Tutorial for Linux Admin and DevOps Engineer

linux-shell-scripting-guide-and-tutorial

Linux User Commands

Linux Admin Commands

Useful Tools in Linux

Linux Shell Scripting Collection and Interview Guide

Linux Troubleshooting Guide

Linux Quiz

Linux Exercise

Linux Bash Scripting Video Tutorial and CBT

Tagged : / / / / / / / / / / / / / / /