Automation DevOps Featured

Get started with brand new Jenkins 2.0 with Docker

Jenkin 2.0

The new version of the Jenkins a.k.a Jenkins 2.0 will be released very soon. Jenkins 2.0 will be bringing us some new amazing features.

  • Pipeline as Code
  •  Improved User Interface and User Experience
  •  Security & plugin Enhancements
  •  New Jenkins WebSite as one stop for getting started guide

The detailed information about the new release can be found out here

In this post, let’s try out new version of the Jenkins with it’s own Docker image.

Jenkins inside Docker

The fastest way to get started is getting the docker image and run containers. The CloudBees has already created a Docker image jenkinsci/jenkins with tag of ‘2.0-beta-2’.

Assuming that, you have Docker ToolBox or similar setup on your machine, you can get the latest image. You can follow my previous post on practical guide to install Docker ToolBox. You can get the image just by pulling it from DockerHub.

I have found some cool writeup on RiotGames blogs about setting up Docker and Jenkins. It’s worth having a look in order to detailed understanding of the Docker and Jenkins.

Jenkins Master and Mounted Data Volume

Let’s build couple of the Docker images in order to setup Jenkins instance with preserved data. There will be two images and containers

  • Two manage Jenkins Master
  • Store Data so that restarting container won’t loos jobs and plugin data

Let’s create Dockerfile to build our Jenkins master.

Now insert following in the Dockerfile


In this Dockerfile, we are creating another image on top of Jenkins Docker image with some jenkins log directory and JAVA options.

Now, we will create another Dockerfile called ‘Dockerfile-data’ so that we can mount that image/containers while launching jenkins-master.

Add the following content to the Dockerfile.

This image will be used to mount volume for the Jenkins master so that we can delete the Jenkins master without worrying about the data.

Build Docker images and run Containers

Now that, we have docker file for the Jenkins Master and Jenkins Data. We can build those images.

  • Jenkins Data Image

  • Jenkins Master Image

We can launch the containers for each image

Now we can see Jenkins 2.0 will be started on Docker host ip and Port 8080 e.g


Setting up Jenkins 2.o

Now that we are running instance of the Jenkins at ‘‘ (Assuming is your Docker-Machine or equivalent IP), we can setup up the things

  • Admin Password

Jenkins 2.0 will ask for the Admin password stored in the Jenkins Master container. We can get it and paste it in the console

  • User Details

The next step is to fill in the required user details in order to login into the Jenkins.

  • Plugins

You can then install default plugins

Now, we have ready instance of Jenkins to configure Jobs and Pipelines.


Exploring Jenkins 2.0 Features

Jenkins features are explained in the brief above but we will demonstrate two powerful features

  • Pipeline as Code

In the previous version of the Jenkins. We have

Pipeline as a code has following benefits

  • Easily define simple and complex pipelines through the DSL in a .
  • Pipeline as code provides a common language to help teams (e.g. Dev and Ops) work together.
  • Easily share pipelines between teams by storing common “steps” in shared repositories.


Here is the demo how to create a default pipeline using Jenkins 2.o. Click on the image below.


  • Multi-branch Pipeline

Now we can create different pipelines as per the GitHub branches. I have created and Github repo ‘jenkins2-docker‘ with multiple branches and configured the Jenkins accordingly.



There are some other features as well but these two are very powerful. I will cover slaves and other features in the next post


Github Repo


Happy DevOps’ing !!

  • Nice one Shashikant. I’m also looking forward to Jenkins 2.0 features.. hope it’s worth the wait.


    • Sure Virendra, It’s worth waiting and I am so excited about it 🙂

  • Hi, how use plugin for build and push docker image?

    • Docker image is already published by CloudBees. It’s called “jenkinsci/jenkins:2.0-beta-2”

  • @ShashikantJ:disqus Trying my hands on as well 😉

    I’m working on a screencast to cover all new features.

  • Gleb Zverinskiy

    I am currently using Jenkins 1.x with docker, my /var/lib/directory is mounted from the host which makes my container ephemeral. If I use the same directory with the new Jenkins image will it be able to run, basically do 1.x plugins and setting work on 2.x Jenkins. I have a lot of jobs and settings and do not want to start over.

    • @glebzverinskiy:disqus

      I’m not sure how have you deployed jenkins in your existing image but a few things to consider:

      Also, why not add the data volume to a container and test it quickly. Wouldn’t take much time to test. Share your findings if you get stuck.

      • Gleb Zverinskiy

        I tested this by doing the following, same way as I run my Jenkins 1.x right now

        docker run -e JENKINS_JAVA_OPTIONS=”-Duser.timezone=America/New_York -Dhudson.model.DirectoryBrowserSupport.CSP= ” –name jenkins_master -d -p 80:8080 -v /home/user/jenkins/:/var/lib/jenkins -v /home/user/jenkins/timezone:/etc/timezone jenkins

        Jenkins fired up no problem, but when I opened the webpage I was taken to a configuration page for plugins and was asked for a login password that was stored in a file(forgot exact location) Because of this one of things is possible, I haven’t had time to play with it much further

        1) ether my configurations were not read
        2) some new config is required and then I would be all set

        I do not use a data container by a folder on host because that makes it easier for me to automate my Jenkins backup

        • I will try to recreate the same scenario and see if I encounter the same issue. Will update you soon.

          • Thanks Virendra for giving it go t recreate, I think Jenkins 2.0 stores password in home/secrets/initialAdminPassword
            we have to cat this file..

  • Hi Shashikant,

    Great work with this procedure and docker images!!

    I’m getting a error when initiate the jenkins and the plugins wasn’t installing with success.

    WARNING: No valid crumb was included in request for /pluginManager/installPlugins. Returning 403.

    Why you aren’t using the docker-compose to create this? And why are you using a docker for data?
    You can share the local volume to the jenkins and get access to the jenkins configuration.

    What do you think of that docker-compose.yml file?

    version: ‘2’


    container_name: jenkins2.0
    build: .
    – “8080:8080″
    – /var/lib/jenkins-2.0-docker:/var/jenkins_home

    • hi Icaro, Thanks for your comment. Apologies for delayed responding 🙁

      I think docker-composer is great idea but was just trying to keep that article very basic who are new to docker. I agree that we can do it that way as well which will be better 🙂

  • Ryan

    i have a developer that needs to edit some files, but vi/vim isnt installed. how would one accomplish this since the container is just running jenkins as the jenkins user?

  • Bright Tsai


  • Oliver Leach

    Greta information and in a simple one pager. Thanks!