Skip to main content
Jenkins Pipeline
CHAPTER 02

Installing Jenkins on Windows, Linux, and Docker

Updated: May 15, 2026
20 min read

# CHAPTER 2

Installing Jenkins on Windows, Linux, and Docker

1. Introduction

Jenkins is a robust application that can run on almost any operating system, but its installation method heavily dictates how easy it will be to maintain and upgrade. While running a simple .war file is great for a quick test (as seen in Chapter 1), professional DevOps engineers must know how to install Jenkins as a dedicated background service. In this chapter, we will explore the three primary ways to install Jenkins: Native Windows, Native Linux (Ubuntu), and the modern industry standard: Docker. We will also walk through the initial unlocking and plugin setup phase.

2. Learning Objectives

By the end of this chapter, you will be able to:
  • Verify Java prerequisites for Jenkins.
  • Install Jenkins natively on an Ubuntu Linux server.
  • Install Jenkins cleanly using Docker containers.
  • Unlock the Jenkins dashboard using the initial admin password.
  • Understand the purpose of the "Suggested Plugins."

3. Beginner-Friendly Explanation

Imagine buying a new high-tech refrigerator (Jenkins).
  • The Windows/Linux Native Install: This is like building the refrigerator into your kitchen cabinets. It works great, but if you move to a new house, it's very difficult to rip it out of the wall and take it with you.
  • The Docker Install: This is like buying a standalone refrigerator with wheels. It has everything it needs built inside it. You can roll it into any house (any server), plug it in, and it works perfectly in exactly the same way. Docker is the preferred way to run Jenkins today.

4. Method 1: Linux (Ubuntu/Debian) Native Install

In traditional enterprise environments, Jenkins is installed on a dedicated Linux virtual machine.

Step-by-Step:

  1. 1. Install Java:
sudo apt update sudo apt install openjdk-17-jdk
  1. 2. Add the Jenkins repository key:
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null
  1. 3. Add the repository to your system:
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null
  1. 4. Install Jenkins:
sudo apt-get update sudo apt-get install jenkins
  1. 5. Start the service:
sudo systemctl start jenkins

5. Method 2: The Modern Standard (Docker)

Docker creates isolated environments called "Containers." Running Jenkins in Docker is cleaner and prevents Java from conflicting with other software on your machine.

Step-by-Step:

  1. 1. Install Docker Desktop on your computer.
  1. 2. Open your terminal and run the official Jenkins container image:
``bash docker run -p 8080:8080 -p 50000:50000 -v jenkinshome:/var/jenkinshome jenkins/jenkins:lts `
  • -p 8080:8080: Maps the Jenkins web interface to your browser.
  • -v jenkinshome...: Creates a "Volume." If you delete the container, your data (passwords, jobs) is saved safely on your hard drive.

6. Mini Project: Set up the Jenkins Server

Whether you used Docker or Native Linux, your Jenkins server is now running on
http://localhost:8080. Let's unlock it.

The Initial Setup Walkthrough:

  1. 1. Unlock Jenkins: When you visit the page, it will ask for an "Administrator password."
  • *If using Docker:* Look at your terminal output. Jenkins prints a long random string of text (e.g., 4a7b8e...). Copy and paste this into the browser.
  • *If using Linux:* Run sudo cat /var/lib/jenkins/secrets/initialAdminPassword to view the password.
  1. 2. Install Plugins: Jenkins is a bare-bones engine. It relies entirely on plugins to do actual work (like talking to Git or Docker). Click "Install suggested plugins". This will take a few minutes as it downloads core features.
  1. 3. Create First Admin User: Fill out the form to create your permanent username and password. Do not lose this!
  1. 4. Instance Configuration: Confirm the Jenkins URL (usually http://localhost:8080). Click "Save and Finish."

7. Real-World Scenarios

A junior engineer at a startup installed Jenkins directly onto their personal Windows laptop. They spent weeks building complex pipelines to deploy the company website. One morning, the developer spilled coffee on the laptop, frying the motherboard. Because Jenkins was installed natively and not backed up, the company lost all of their deployment automation. If they had used a Docker container with an external volume mounted to cloud storage, they could have spun up the exact same Jenkins server on a new laptop in under 5 minutes.

8. Best Practices

  • Always use the LTS Release: When downloading Jenkins, you will see "Regular Releases" (weekly) and "Long-Term Support" (LTS). For professional environments, *always* choose LTS. Weekly releases contain cutting-edge features but often have bugs that can break your pipelines.

9. Security Recommendations

  • Change the Default Password: The initialAdminPassword is exactly that—initial. Immediately create a strong, dedicated Admin user and delete or disable the temporary initial configuration.

10. Troubleshooting Tips

  • Plugin Installation Failures: Occasionally, during the "Install suggested plugins" phase, some plugins might fail (show a red X) due to network timeouts. Simply click "Retry" or continue to the dashboard; you can manually install missing plugins later.

11. Exercises

  1. 1. What is the primary advantage of running Jenkins inside a Docker container versus installing it natively on a Windows host?
  1. 2. What is the purpose of the /var/jenkinshome directory (or volume) in a Jenkins installation?

12. FAQs

Q: Do I need to know Java programming to use Jenkins? A: No. While Jenkins is written in Java, you interact with it via a web UI and write pipelines using a language called Groovy (which is very similar to standard scripting languages). You do not need to compile or write raw Java code.

13. Interview Questions

  • Q: Explain the concept of a Docker Volume in the context of a containerized Jenkins deployment. Why is a volume critical for stateful applications like Jenkins?
  • Q: A developer complains that their Jenkins server crashed after a recent apt-get upgrade` command on their Ubuntu server. What architectural strategy would prevent host-level OS updates from breaking the CI/CD server?

14. Summary

In Chapter 2, we moved beyond the basic executable file and learned how to properly install Jenkins for professional use. We compared native Linux installations to the modern, portable Docker container approach. We unlocked the Jenkins security gate, initialized the core plugins required to make Jenkins functional, and established our primary Administrator account. Our robotic butler is now officially hired and waiting for instructions.

15. Next Chapter Recommendation

Before we tell Jenkins what to do, we need to learn how to navigate its interface and configure its settings. Proceed to Chapter 3: Jenkins Dashboard and User Interface.

Finish this Chapter

Save your progress on your learning path and prepare for coding interview challenges.

Discussion

Join the discussion

Log in or create a free account to participate.

Sort: ·