How to Install Jenkins using Docker Compose – The Process

Appinventiv Technologies
App Development Company
January 28, 2025
How to Install Jenkins using Docker Compose
copied!

Jenkins and Docker sync well together. Cloud containers are one powerful tool for building software in various environments; moreover, Jenkins is the most suitable tool to run inside a container. 

Although the frequently occurring questions are: 

  • How do you manage a Jenkins controller and agents together in Docker? 
  • What if the container crashes? And 
  • How do you back up the data after Jenkins is containerized? 

This article answers all your questions with the clarity of how to install Jenkins the right way. Using Docker compose will undoubtedly make things faster and reusable. So let’s get started with the basic answers. 

What is Jenkins?

Jenkins is a self-contained, open-source automation tool that can be used to automate all tasks related to building, testing, and delivering or deploying software. Jenkins is synonymous with continuous integration and continuous delivery (CI/CD).

The below image shows Jenkins integration with various DevOps tools.

Jenkins integration with various DevOps tools

[Also Read: Best productivity tools for mobile app developers]

What are containers?

Containers are software packages containing all the necessary elements to run in any environment. Multiple containers can run on the same machine and share the OS kernel with other containers.

What are containers

What is Docker Compose?

It’s a tool for defining how to run multiple containers in a single configuration file and start, stop, and restart them with a single command.

Running Jenkins with Docker compose 

Prerequisites

Tap for our assistance

Run these commands in terminal

Change Host Name to Jenkins

> sudo hostname Jenkins

Install docker-compose

> sudo apt update

> sudo apt-get install docker-compose -y

Check version of docker by command 

> docker-compose --version

Add current user to the docker group

> sudo usermod -aG docker $USER

 Create Directory

> mkdir ~/jenkins

Jenkins setup

Create docker-compose.yml fileExecute yaml file

> sudo vi docker-compose.yml

version: '3.3'

services:

jenkins:

image: jenkins/jenkins:lts

restart: unless-stopped

privileged: true

user: root

ports:

- 8080:8080

container_name: jenkins

volumes:

- ~/jenkins:/var/jenkins_home

- /var/run/docker.sock:/var/run/docker.sock

- /usr/local/bin/docker:/usr/local/bin/docker

Note: Paste this code in the yaml file.

Execute yaml file

> sudo docker-compose up -d

Now you can access the browser with the ip of the instance with port 8080. It will show up like the page below.

access the browser with the ip of the instance with port 8080

To generate an Administrator password, use the below command.

> docker exec jenkins-lts cat /var/jenkins_home/secrets/initialAdminPassword

                                                 OR 

> docker logs jenkins | less

Enter the password and continue to the next page.

Select Install Suggested Plugins on the next page; next, Enter a username and password and click Save and Continue.

Install Suggested Plugins

The next page allows you to change your controller’s hostname. You can accept the default and click Save and Finish.

change your controller's hostname

Jenkins is ready to set up an agent!

What are some of the top business benefits of running Jenkins in a docker container? 

Businesses prefer Jenkins in a docker container when they want most of the configuration from the server under control. Most organizations keep Jenkins in the pipeline when they want the ability to run the server locally on any machine while experimenting with new features and configurations. 

Installing Jenkins with Docker composer will help businesses with:

  • Easy deployment and scalability 
  • Higher density with more workload running capacity 
  • Faster delivery of applications
  • Flexible management of environment

Wrapping up

In this article, we discovered how to configure a Jenkins controller with Docker compose. We asked you to set it up in volume so you can save the instance data between restarts. 

This is just the beginning of Docker Composer’s capabilities. You can finally encounter how the tool helps you administer CI/CD infrastructure. It’s time to get started with Docker compose today to extend the above mentioned benefits in your pipeline. 

Need assistance? Consult our experts for personalized solutions.

THE AUTHOR
Appinventiv Technologies
App Development Company
Prev PostNext Post
Let's Build Digital Excellence Together
Let's Build Digital Excellence Together
Read More Blogs
Multicloud Strategy

How to Build a Robust Multi-Cloud Strategy for Future Readiness

Key takeaways: Multi-cloud adoption is growing and 76% of enterprises have already embraced multi-cloud environments. Avoiding vendor lock-in is a major driver for businesses moving to multi-cloud strategies. Cost optimization and enhanced security are key benefits of multi-cloud adoption. Businesses must align their multi-cloud strategy with business objectives for scalability, security, and innovation. Seamless integration…

Nayan Sharma
Cloud analytics for business growth

How Cloud Analytics Helps Businesses Make Data-Driven Decisions Faster

Key takeaways: Cloud analytics accelerates decision-making by offering real-time insights and scalability. Businesses gain cost efficiency, enhanced agility, and improved accuracy with cloud analytics. Leveraging AI and big data empowers faster, smarter decision-making in industries like e-commerce, healthcare, and finance. While implementing cloud analytics, businesses face challenges like data security and integration, but there are…

Sudeep Srivastava
Legacy systems to cloud migration

Transforming Legacy Systems with Cloud Migration: The Whys and Hows

Key takeaways: Legacy systems hinder innovation, security, and agility, making cloud migration a strategic imperative. A successful legacy to cloud migration hinges on careful planning, choosing the right strategy, and robust execution. Benefits of cloud migration for legacy systems include enhanced scalability, fortified security, and significant cost optimization. Industry-wide use cases demonstrate the transformative power…

Nayan Sharma
Mobile App Consulting Company on Clutch Most trusted Mobile App Consulting Company on Clutch
appinventiv India
INDIA

B-25, Sector 58,
Noida- 201301,
Delhi - NCR, India

appinventiv USA
USA

79, Madison Ave
Manhattan, NY 10001,
USA

appinventiv Australia
Australia

Appinventiv Australia,
East Brisbane
QLD 4169, Australia

appinventiv London UK
UK

3rd Floor, 86-90
Paul Street EC2A 4NE
London, UK

appinventiv UAE
UAE

Tiger Al Yarmook Building,
13th floor B-block
Al Nahda St - Sharjah

appinventiv Canada
CANADA

Suite 3810, Bankers Hall West,
888 - 3rd Street Sw
Calgary Alberta