Jenkins in Docker

We love Jenkins and we love Docker, so let’s get them working together.

We are assuming you already have Docker installed on your environment.

Here is the terminal command to use:

docker run -p 8080:8080 -p 50000:50000 -v /Jenkins/jenkins-master:/var/jenkins_home --name jenkins-master  jenkins/jenkins:lts

Let’s break it down:

-p 8080:8080Run Jenkins on the default port 8080 in the hosted environment
-p 50000:50000Again this is for Jenkins to be exposed to the host environment
-v {host location}:/var/jenkins_homePersist the data to your local volume
–name jenkins-mastergive the Docker an image name that we can understand
jenkins/jenkins:ltsuse the latest stable build version

Just make sure you have the {host location} in the docker Resource/File Sharing in order for the image to be able to see that location.

It is really that simple, just remember the initial password will be held in the following folder on your Docker Image:

/var/jenkins_home/secrets/initialAdminPassword