Jenkins Course
Installation Overview
There are three ways to install Jenkins — and picking the wrong one for your situation will cause you headaches for months. This lesson walks through all three so you know exactly which one to choose before you run a single command.
Installing Jenkins isn't hard. But teams often install it the fastest way rather than the right way — and then six months later they're dealing with Java version conflicts, manual upgrade pain, or a Jenkins instance that can't be moved to a new server without hours of work. A few minutes of planning here saves a lot of pain later.
The Three Installation Methods
Think of these three methods like three ways to set up a workspace. You could rent a desk in a co-working space (Docker — quick, self-contained, easy to pack up). You could lease a dedicated office in a building managed by someone else (cloud — someone else handles the building, you manage your space). Or you could own and build your own office from scratch on your own land (native install — total control, total responsibility).
Each approach has a time and a place. Here's the full picture:
Native Install
Linux / macOS / Windows
- Jenkins runs directly on the OS
- Full control over Java version
- Upgrades done manually
- Best for: dedicated servers, on-premise teams
Docker
Containerised Jenkins
- Runs in an isolated container
- Easy to start, stop, move
- Upgrade = pull new image
- Best for: local dev, learning, testing
Cloud / Kubernetes
AWS, GCP, Azure or K8s
- Runs on managed infrastructure
- Scales automatically with demand
- Higher setup complexity upfront
- Best for: large teams, cloud-native orgs
What You Need Before Any Install
Regardless of which method you choose, there is one hard requirement: Java. Jenkins is a Java application. No Java, no Jenkins. Full stop.
Jenkins requires Java 17 or Java 21 as of the current LTS release. Java 11 was previously supported but is now end-of-life for Jenkins. This trips up a lot of people who have an older Java version already on their system and wonder why Jenkins won't start.
What is Java?
Java is a programming language and runtime environment. Jenkins itself is written in Java, which means the Java runtime (JRE or JDK) must be installed on any machine running Jenkins — the master and every agent. Think of Java as the engine that Jenkins runs on top of. Without it, Jenkins has nothing to run on.
Method 1 — Native Install on Linux (Ubuntu)
This is the most common production install method. Jenkins gets installed directly onto a Linux server — just like installing any other software package. Once it's running, it starts automatically on boot and behaves like any other system service.
The scenario:
You're a DevOps engineer at a logistics company. Your team has been given a fresh Ubuntu 22.04 server to run Jenkins on. No Docker, no Kubernetes — just a clean Linux box. Your job is to get Jenkins installed and running as a system service before end of day. These are the exact commands you'd run.
Tools used in these commands:
- apt — Ubuntu's package manager. Think of it as the App Store for Linux. It downloads and installs software from trusted sources called repositories.
- wget — a command-line tool that downloads files from the internet. We use it to download the Jenkins repository signing key.
- systemctl — a Linux tool for managing system services. It lets you start, stop, restart, and check the status of background programs like Jenkins.
- curl — another download tool, similar to wget. Used here to get the Jenkins repository configuration file.
# Step 1: Install Java 21 — Jenkins will not start without this
sudo apt update
sudo apt install -y fontconfig openjdk-21-jre
# Confirm Java installed correctly — you should see "openjdk version 21..."
java -version
# Step 2: Add the Jenkins package repository so apt knows where to find Jenkins
# Download the Jenkins repo signing key — this proves the packages are genuine
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
# Add the Jenkins repo to apt's list of sources
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
# Step 3: Install Jenkins now that apt knows where to find it
sudo apt update
sudo apt install -y jenkins
# Step 4: Start Jenkins and enable it to start automatically on every reboot
sudo systemctl start jenkins
sudo systemctl enable jenkins
# Step 5: Check Jenkins is actually running — look for "active (running)"
sudo systemctl status jenkins
Where to practice this: You need a Linux machine or VM to run these commands. Free options: Katacoda Jenkins Playground gives you a live Ubuntu terminal instantly. Alternatively, spin up a free Google Cloud or AWS Free Tier Ubuntu VM and run these commands directly. The official step-by-step guide is at jenkins.io/doc/book/installing/linux.
● jenkins.service - Jenkins Continuous Integration Server
Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2024-03-13 09:14:22 UTC; 5s ago
Main PID: 3821 (java)
Tasks: 38 (limit: 4915)
Memory: 312.4M
CPU: 18.432s
CGroup: /system.slice/jenkins.service
└─3821 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/jenkins/jenkins.war
Mar 13 09:14:22 jenkins-master-01 systemd[1]: Started Jenkins Continuous Integration Server.
Mar 13 09:14:26 jenkins-master-01 jenkins[3821]: Jenkins initial setup is required.
Mar 13 09:14:26 jenkins-master-01 jenkins[3821]: Please use the following password to proceed:
Mar 13 09:14:26 jenkins-master-01 jenkins[3821]: a3f2b1c9d4e5f6a7b8c9d0e1f2a3b4c5
Mar 13 09:14:26 jenkins-master-01 jenkins[3821]: This may also be found at:
Mar 13 09:14:26 jenkins-master-01 jenkins[3821]: /var/lib/jenkins/secrets/initialAdminPassword
What just happened?
Active: active (running)— this is the line you want to see. It confirms Jenkins started successfully and is currently alive. If you seefailedhere instead, check/var/log/jenkins/jenkins.logfor the error.Main PID: 3821 (java)— Jenkins is just a Java process. The process name in brackets isjava, notjenkins. This is normal. If you ever need to force-kill Jenkins, this is the PID you'd use.Memory: 312.4M— Jenkins is using about 312MB of RAM just to start up with no jobs running. Plan for at least 1GB on a real server, more if you have many plugins or heavy builds.- The initial admin password — Jenkins prints a one-time setup password when it starts for the first time. You need this to log in and finish setup through the browser. It's also saved to
/var/lib/jenkins/secrets/initialAdminPasswordin case you miss it in the logs. enabledin the Loaded line — because we ransystemctl enable jenkins, Jenkins will start automatically every time the server reboots. Without that command, you'd have to manually start it after every restart.
Method 2 — Docker Install
Docker is a tool that packages software into isolated containers — self-contained boxes with everything the software needs to run, bundled together. For Jenkins, this means you don't need to install Java, worry about OS compatibility, or manage dependencies manually. You pull the Jenkins Docker image and it comes with everything pre-installed.
The scenario:
You're a backend developer who wants to learn Jenkins on your own laptop without touching your system's Java install or setting up a full server. Docker lets you spin up a complete Jenkins instance in one command and throw it away just as easily when you're done.
Tools used in this command:
- Docker — a platform that runs software in containers. A container is like a lightweight virtual machine — isolated from the rest of your system. Install Docker from docs.docker.com/get-docker before running this command.
- docker run — the command that starts a new container from an image. An image is a pre-built snapshot of software — like a template. Jenkins publishes official images to Docker Hub.
- -v (volume) — connects a folder on your machine to a folder inside the container so Jenkins data isn't lost when the container stops.
# Pull and run the official Jenkins LTS image
# LTS = Long Term Support — the stable release recommended for most users
docker run \
--name jenkins-local \ # give the container a friendly name
--detach \ # run in background so your terminal stays free
--publish 8080:8080 \ # map port 8080 on your machine to port 8080 in the container
--publish 50000:50000 \ # port 50000 is used for agent connections
--volume jenkins-data:/var/jenkins_home \ # save Jenkins data to a named volume
jenkins/jenkins:lts-jdk21 # the official Jenkins image with Java 21 included
# Check the container started successfully
docker ps
# Read the initial admin password from inside the container
docker exec jenkins-local \
cat /var/jenkins_home/secrets/initialAdminPassword
Where to practice this: Install Docker Desktop on your laptop from docs.docker.com/get-docker — it's free and works on Windows, Mac, and Linux. Once Docker is running, paste these commands into your terminal. Jenkins will be available at http://localhost:8080 within about 30 seconds. The official Docker install guide is at jenkins.io/doc/book/installing/docker.
Unable to find image 'jenkins/jenkins:lts-jdk21' locally lts-jdk21: Pulling from jenkins/jenkins a378f10b3218: Pull complete 3a9bc1f49b47: Pull complete Digest: sha256:4a2b...f1c9 Status: Downloaded newer image for jenkins/jenkins:lts-jdk21 e7d3a1b2c4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3 CONTAINER ID IMAGE COMMAND STATUS PORTS e7d3a1b2c4f5 jenkins/jenkins:lts-jdk21 "/usr/bin/tini -- /u…" Up 12 seconds 0.0.0.0:8080->8080/tcp a3f2b1c9d4e5f6a7b8c9d0e1f2a3b4c5
What just happened?
- "Unable to find image locally" — Docker looked for the Jenkins image on your machine first, didn't find it, and automatically downloaded it from Docker Hub (Docker's public image registry). This only happens the first time.
- The long hex string after the run command — that's the container ID. Docker assigns every container a unique identifier. You can use this ID (or the friendly name
jenkins-local) to stop, start, or inspect the container later. 0.0.0.0:8080->8080/tcp— confirms port mapping is working. Anything hitting port 8080 on your machine is forwarded into the container's Jenkins. Openhttp://localhost:8080in your browser and you'll see the Jenkins setup screen.- The last line (the password) — the
docker execcommand ran a command inside the running container and printed the initial admin password. This is the password you'll paste into the Jenkins setup screen in your browser. --volume jenkins-data:/var/jenkins_home— without this flag, all your Jenkins configuration would be lost the moment you stop the container. The volume keeps your data safe on your machine even when the container is not running.
Which Method Should You Use?
Teacher's Note
For following this course, use Docker. One command, Jenkins is running, and nothing touches your system Java. That's the right call.
Practice Questions
1. What runtime must be installed on any machine running Jenkins before Jenkins can start?
2. What is the name of the file Jenkins generates on first start that contains the one-time setup password?
3. What port does Jenkins listen on by default when you access it in the browser?
Quiz
1. What is the main advantage of installing Jenkins via Docker compared to a native install?
2. Which command makes Jenkins start automatically every time the Linux server reboots?
3. What does the --volume flag do in the Docker run command?
Up Next · Lesson 6
Initial Setup and UI
Jenkins is installed — now let's walk through the setup wizard and get familiar with every part of the UI before you build your first job.