Tech Me More

To quench our thirst of sharing knowledge about our day to day experience & solution to techincal problems we face in our projects.

Advertise with us !
Send us an email at

Friday, May 17, 2019

Install Jenkins with Docker file & preinstalled plugins. [Copy existing .jpi/.hpi file to docker image.]

Create a new file with name as Dockefile and add the below content.

FROM jenkins/jenkins:lts
USER root

if you want to copy any existing .hpi/.jpi file in your docker image, please add the below command in Dockerfile (Eg. If we want to copy perforce.jpi plugin from local machine to docker image )

COPY perforce.jpi /var/jenkins_home/plugins/

If you want Jenkins to preinstall plugins create a plugins.txt file with below content.

pluginid : version_info (For example if you want to install notification plugin with 1.13 version, we need to specify it as below, if we don’t pass version info, it will take the latest version)


Content of the plugins.txt file looks like as follow.

to copy the plugins.txt file to docker image, add the below command in Dockerfile.

COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN /usr/local/bin/ < /usr/share/jenkins/ref/plugins.txt 

Final content of Dockerfile will be as follows:

Now create a docker image using the Dockerfile.
Run the command : docker build -t “tagName” path_to_docker_file

Eg: docker build -t “test” /Users/ptech/mydocker

After completion of the above command, you will see a new docker image getting created. To check just run docker images

This means your docker image with tag name as blogging is created.

To create a container using the above create image please run the below command.

docker run -p 8001:8080 -p50000:50000 blogging

you can change the port from 8001 to whatever you want.

Go to http://localhost:8001 to access the Jenkins .

Useful link : Jenkins official git

No comments: