Docker | Jenkins plugin (original) (raw)

Last Updated : 23 Jul, 2025

Combining Jenkins with Docker in CI/CD is a powerful duo. Jenkins, an open-source automation server, is used in the application development process to facilitate the implementation of CI/CD processes. Docker is a platform for developers to bundle their applications into containers, which are used to achieve consistency across different environments—development and production. The Jenkins Docker plugin allows Docker to be smoothly integrated with Jenkins jobs to handle the building and deployment of containers ultimately improving the consistency, scalability, and reliability of the CI/CD process.

Primary Terminologies

Step-by-Step Process: Setting Up the Docker Plugin in Jenkins

Step 1: Install Docker

Install docker by using following command

sudo yum -y install docker

Screenshot-2024-09-04-132100

Now start and enable docker

sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl status docker

Screenshot-2024-09-04-132158

Step 2: Install Jenkins

Now install Jenkins by following commands

sudo wget -O /etc/yum.repos.d/jenkins.repo \

https://pkg.jenkins.io/redhat-stable/jenkins.repo

sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key

sudo yum upgrade

sudo yum -y install java-17*

Screenshot-2024-09-04-132236

Now install jenkins

sudo yum -y install jenkins

Screenshot-2024-09-04-132325

Start and enable jenkins

sudo systemctl start jenkins
sudo systemctl enable jenkins
sudo systemctl status jenkins

Screenshot-2024-09-04-132406

After completion of jenkins installation now connect by using public-ip:8080

Screenshot-2024-09-04-132440

Step 3: Install the Docker Plugin in Jenkins

Screenshot-2024-09-04-132615

Step 4: Configure Docker in Jenkins

Screenshot-2024-09-04-132734

Screenshot-2024-09-04-133005

Step 5: Create a Jenkins Pipeline with Docker:

Screenshot-2024-09-04-15

Example of a Jenkins file that builds a Docker image:

Running a Docker Container:

Use the docker command in a Jenkins pipeline to run a container.

pipeline {

agent any

stages {

stage('Run Docker Container') {

steps {

sh 'docker run --rm hello-world'

}

}

}

}

Screenshot-2024-09-04-141904

Now build the job

Screenshot-2024-09-04-141719

Here We see Output

Screenshot-2024-09-04-141754

Here we see that pipeline console

Screenshot-2024-09-04-153419

Here is the pipeline view of job

Screenshot-2024-09-04-153706

Conclusion

A very strong solution to enhance the CI/CD process: Integrating Docker with Jenkins via the Docker plugin. Running Jenkins jobs inside Docker containers makes builds consistent and isolated, reducing the chance of errors due to the inconsistency of the environment

In this article, you have learned about installing and configuring the Jenkins Docker plugin, creating a Docker-based Jenkins job, and its management, in addition to understanding the benefits. By following the steps outlined above and best practices, an optimized CI/CD pipeline can be achieved for fast and reliable software delivery. As you iterate the setup Jenkins and Docker will come together to help manage complex workflows scale builds, and maintain high quality in your software projects.