In the previous lesson you saw what Jenkins is and what problems it solves. Now it is time to get it running. Jenkins can be installed in many ways: as a Docker container, as an operating system package, as a single executable Java file, or with installers for Windows and macOS. In this lesson you will learn the requirements, the available options and how they differ, how to start and manage the service, how to unlock Jenkins the first time and how to complete the setup wizard. By the end you will be able to install Jenkins in any common environment and you will understand what lives inside its data directory.

Prerequisites

Java

Jenkins is a Java application, so it needs a Java Virtual Machine (JVM) to run. Current Jenkins LTS releases require Java 17 or Java 21. Older versions, such as Java 8 or 11, are no longer supported.

  • If you install Jenkins with Docker, you do not need to install Java: the official image already includes it.
  • If you install it with packages or with the WAR file, you must install Java yourself.

To check which Java version you have:

java -version

The output should show something like openjdk version "21.0.x". If you see 17 or 21, you are ready; if the command does not exist or shows an older version, you will need to install a modern JDK or JRE.

Hardware

Use RAM Disk Comment
Minimum for trying it out 256 MB 1 GB It starts, but it will be slow and will soon fall short.
Recommended for learning (this course) 2-4 GB 10 GB or more Enough to build orders-api with Maven.
Small team in production 4 GB or more 50 GB or more Disk usage grows with build histories, artifacts and plugins.

Disk is usually the first resource to run out: every build stores its output and, if they are not cleaned up, workspaces and artifacts take up a lot of space.

Network Ports

Port Use
8080 Jenkins web interface and REST API (default value; it can be changed).
50000 TCP connection for inbound agents. Only needed if you connect agents of that type; we will cover it in module 5.

Make sure port 8080 is not already taken by another application on your machine (some development servers use it by default).

LTS vs Weekly Releases

Jenkins publishes two release lines:

Line Frequency For whom Characteristics
Weekly Every week Those who want new features as soon as possible Includes the latest features and fixes, but with less time for validation.
LTS (Long-Term Support) Roughly every 4 weeks, with a new baseline every 12 weeks Production environments and most teams A stable weekly release is chosen and only important fixes and security fixes are applied to it.

Recommendation: always use the LTS unless you have a specific reason not to. It is the one we will use throughout the course. In Docker, the LTS image is identified by tags containing lts, such as jenkins/jenkins:lts-jdk21.

Installation Options Compared

Option Advantages Drawbacks Ideal for
Docker container Fast, isolated, no Java installation, easy to delete and recreate Requires some Docker knowledge; build tools must be inside the container or on agents Learning, labs and many real-world environments
Linux packages (apt, dnf) Integration with systemd, upgrades through the package manager Installs Java and Jenkins directly on the system Dedicated Linux servers
WAR file Works on any system with Java; no administrator privileges required Not installed as a service; you have to manage startup yourself Quick tests, restricted environments
Windows installer (MSI) Graphical wizard; registers itself as a Windows service Windows-specific paths and permissions Teams that build software for Windows
macOS (Homebrew) A single command Intended for local use, not for production Trying Jenkins on a Mac

In this course we will use Docker, because it lets every student have exactly the same environment. In The Course Project we will set up the final environment with docker compose; here you will see the basic installation with docker run so you understand each piece.

Installing with Docker

You need Docker Engine (Linux) or Docker Desktop (Windows/macOS) installed. Check that it works with docker version.

This command starts a trial Jenkins:

docker run -d \
  --name jenkins-trial \
  -p 8080:8080 \
  -p 50000:50000 \
  -v jenkins_trial_home:/var/jenkins_home \
  --restart=on-failure \
  jenkins/jenkins:lts-jdk21

Option by option:

  • docker run: creates and starts a new container.
  • -d (detached): runs it in the background and gives you your terminal back.
  • --name jenkins-trial: gives the container a fixed name so you can refer to it in other commands (docker logs jenkins-trial, docker stop jenkins-trial...).
  • -p 8080:8080: publishes the container's port 8080 on port 8080 of your machine. The format is host_port:container_port. If your port 8080 is taken, you can use -p 9090:8080 and browse to http://localhost:9090.
  • -p 50000:50000: publishes the port for inbound agents. You will not need it yet, but it is common to include it.
  • -v jenkins_trial_home:/var/jenkins_home: creates (or reuses) a Docker volume called jenkins_trial_home and mounts it at /var/jenkins_home, the directory where Jenkins stores all of its configuration and data. Without this volume, deleting the container would wipe everything.
  • --restart=on-failure: if the Jenkins process exits with an error, Docker starts it again automatically.
  • jenkins/jenkins:lts-jdk21: the official Jenkins image, in its LTS version and with Java 21 included.

Check that the container is running:

docker ps --filter name=jenkins-trial

You should see a line with the status Up. The first startup takes anywhere from 30 seconds to a couple of minutes.

Heads-up: we named this container jenkins-trial on purpose. When you set up the course environment in lesson 01-04 you will use a different name (jenkins-controller) and the same port 8080, so you will have to stop and remove this trial container first (docker rm -f jenkins-trial).

Installing with Linux Packages

The Jenkins project maintains official repositories for the main distributions. Adding them lets you install and upgrade Jenkins with the system's package manager.

Debian and Ubuntu (apt)

First, install Java and the fontconfig library (Jenkins needs it to generate some charts):

sudo apt update
sudo apt install -y fontconfig openjdk-21-jre
java -version

Next, add the signing key and the stable (LTS) repository:

sudo mkdir -p /etc/apt/keyrings
sudo wget -O /etc/apt/keyrings/jenkins-keyring.asc \
  https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
echo "deb [signed-by=/etc/apt/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/" \
  | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt update
sudo apt install -y jenkins

What each part does:

  • sudo mkdir -p /etc/apt/keyrings: creates the directory where third-party repository keys are stored (if it already exists, it does nothing).
  • wget -O .../jenkins-keyring.asc <url>: downloads the public key the Jenkins project uses to sign its packages. This way apt can verify that what you install has not been tampered with.
  • echo "deb [signed-by=...] https://pkg.jenkins.io/debian-stable binary/": defines the repository. signed-by specifies which key must validate that repository, and debian-stable is the LTS line (the debian repository, without -stable, is the one for weekly releases).
  • sudo tee /etc/apt/sources.list.d/jenkins.list: saves that line to an apt sources file.
  • apt update and apt install jenkins: refresh the package list and install Jenkins.

Important: the Jenkins project periodically renews its signing key, and the key file name may change. If apt update shows a NO_PUBKEY or signature error, check the official page https://pkg.jenkins.io/debian-stable/ and copy the exact URL of the current key.

RHEL, Rocky Linux, AlmaLinux and Fedora (dnf)

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 dnf install -y fontconfig java-21-openjdk
sudo dnf install -y jenkins
sudo systemctl daemon-reload
  • The first command downloads the LTS repository definition (redhat-stable).
  • rpm --import imports the public signing key (with the same caveat about it being renewed).
  • Java 21 and fontconfig are installed, followed by Jenkins.
  • systemctl daemon-reload makes systemd reread the service definitions and pick up the new jenkins service.

Starting and Managing the Service with systemctl

The packages install Jenkins as a systemd service that runs as the jenkins system user:

sudo systemctl enable --now jenkins   # Enables automatic startup and starts it right away
sudo systemctl status jenkins         # Shows whether it is active and the latest log lines
sudo systemctl restart jenkins        # Restarts the service
sudo systemctl stop jenkins           # Stops it
sudo journalctl -u jenkins -f         # Follows the service log in real time

If you need to change the port (for example, to 8081), do not edit the package's own file; create an additional configuration instead:

sudo systemctl edit jenkins

An editor will open. Add these lines, save, and restart the service:

[Service]
Environment="JENKINS_PORT=8081"

systemctl edit saves your changes in an override file that survives package upgrades. In package-based installations, Jenkins data is stored in /var/lib/jenkins.

Installing with the WAR File

Jenkins is also distributed as a single jenkins.war file, which contains an embedded web server. All you need is Java:

wget https://get.jenkins.io/war-stable/latest/jenkins.war
java -jar jenkins.war --httpPort=8080
  • wget ...war-stable/latest/jenkins.war: downloads the latest LTS version of the WAR.
  • java -jar jenkins.war: starts Jenkins with the installed JVM.
  • --httpPort=8080: the port the web interface will listen on.

Jenkins will run for as long as the terminal stays open; pressing Ctrl+C stops it. By default it stores its data in ~/.jenkins (the home directory of the user running it). You can change this with the JENKINS_HOME environment variable:

JENKINS_HOME=/opt/jenkins-data java -jar jenkins.war --httpPort=8080

This approach is handy for tests or for machines where you do not have administrator privileges, but on a real server Docker or the packages are preferable, since they handle automatic startup.

Windows and macOS

  • Windows: download the LTS MSI installer from the official Jenkins website. The wizard asks for the account the service will run under, the port and the JDK path (17 or 21), and registers Jenkins as a Windows service, which you can manage from the Services console (services.msc).
  • macOS: the simplest way is Homebrew:
brew install jenkins-lts
brew services start jenkins-lts

brew install jenkins-lts installs the LTS version, and brew services start starts it in the background and configures it to launch when you log in.

On both systems, Docker Desktop is still an excellent alternative, and it is the one we will use in the course.

Unlocking Jenkins: The Initial Password

The first time you open http://localhost:8080, Jenkins shows the Unlock Jenkins screen. To prevent anyone who reaches the URL from configuring the server, Jenkins generates a random password and stores it in a file called initialAdminPassword inside secrets/.

Where to find it depending on the installation method:

Method File path How to read it
Docker /var/jenkins_home/secrets/initialAdminPassword (inside the container) docker exec jenkins-trial cat /var/jenkins_home/secrets/initialAdminPassword
Linux package /var/lib/jenkins/secrets/initialAdminPassword sudo cat /var/lib/jenkins/secrets/initialAdminPassword
WAR ~/.jenkins/secrets/initialAdminPassword cat ~/.jenkins/secrets/initialAdminPassword
Windows (MSI) The path shown on the unlock screen itself Open the file with administrator privileges

With Docker there is a second option: the password also appears in the log of the first startup:

docker logs jenkins-trial

Look for a block delimited by asterisks with the text "Please use the following password to proceed to installation". The hexadecimal string below it is the password. Copy it and paste it into the Administrator password field.

  • docker exec jenkins-trial cat ... runs the cat command inside the container and shows you the result.
  • docker logs jenkins-trial shows everything Jenkins has written to its standard output since it started.

The Setup Wizard

Once Jenkins is unlocked, a wizard with several steps appears.

  1. Customize Jenkins

You have two options:

Option What it does When to choose it
Install suggested plugins Installs a set of community-recommended plugins: Git, Pipeline, credentials, folders, stage views, etc. Almost always, and especially while you are learning. This is the one we will use in the course.
Select plugins to install Shows the list of suggested plugins and lets you check or uncheck each one. When you already know exactly what you need and want a minimal installation.

The installation takes a few minutes, because it downloads the plugins from the update center. If any of them fail (usually because of network problems), the wizard lets you retry.

  1. Create First Admin User

Enter a username, a password, your full name and an email address. This user will have full control over Jenkins. Use a strong password even on your local machine and keep it in a password manager. If you choose Skip and continue as admin, the user will be admin and its password will remain the one from initialAdminPassword, which is not advisable.

  1. Instance Configuration

This is where you set the Jenkins URL: the address users and other systems use to reach Jenkins. It is used to generate links in notifications, emails and webhooks. Locally, http://localhost:8080/ is correct. On a real server you should enter its final name, for example https://jenkins.tecnoshop.local/. You can change it later from Manage Jenkins → System.

  1. Jenkins is ready!

Click Start using Jenkins and you will land on the main dashboard, which we will explore in Jenkins Dashboard Overview.

A Look at JENKINS_HOME

Everything Jenkins knows lives in a single directory: JENKINS_HOME. That is why the Docker volume is so important, and why backups focus on it (we will cover this in Backing Up and Restoring Jenkins).

You can list its contents in Docker with:

docker exec jenkins-trial ls /var/jenkins_home

The most relevant items:

Item Contents
config.xml Global Jenkins configuration (security, number of executors, views...).
jobs/ One subdirectory per job, with its config.xml and the history of its builds (builds/).
plugins/ The installed plugins (.jpi/.hpi files and their unpacked folders).
secrets/ Internal keys, such as the one that encrypts credentials, and the initialAdminPassword. Highly sensitive.
users/ Users in Jenkins' internal user database.
nodes/ Agent configuration.
workspace/ Working directories for builds that run on the controller itself.

Do not edit these files by hand while Jenkins is running: the right way to change the configuration is through the web interface or the configuration-as-code tools we will see later.

Verifying That Everything Works

Run these checks after any installation:

  1. Open http://localhost:8080 and sign in with your administrator user.
  2. Check the version in the bottom-right corner of the interface or under Manage Jenkins → About Jenkins.
  3. From the terminal, verify that the server responds:
curl -sI http://localhost:8080/login | head -n 5
  • curl -sI sends a request asking only for the headers (-I) and without a progress bar (-s).
  • You should see HTTP/1.1 200 OK and an X-Jenkins header with the version number.
  1. Check that there are no serious errors in the log (docker logs jenkins-trial or journalctl -u jenkins).

Common Mistakes and Tips

  • "Address already in use" or the container does not start: another process is using port 8080. Use a different host port (-p 9090:8080) or stop that process.
  • Wrong Java version: if Jenkins does not start after installing it with packages, check java -version. The current LTS will not start on Java 11 or earlier. If you have several versions, sudo update-alternatives --config java (Debian/Ubuntu) lets you choose the default one.
  • Forgetting the volume in Docker: without -v ...:/var/jenkins_home, deleting the container wipes out your jobs, users and plugins.
  • Not finding the initial password: make sure you are looking at the path that matches your installation method. With Docker, the file is inside the container, not on your machine.
  • Plugins that fail to install: it is almost always a network or proxy problem. Click Retry; if it persists, check the server's connectivity to https://updates.jenkins.io.
  • Using the weekly release in production: unless you have specific needs, stick with the LTS.
  • Tip: write down the administrator user you create and keep it somewhere safe. Recovering access without it is possible, but tedious.

Exercises

Exercise 1. Install Jenkins with Docker following this lesson, but publish it on port 9090 of your machine. Unlock it using docker logs, install the suggested plugins and create your administrator user.

Exercise 2. Laura needs to install Jenkins LTS on a TecnoShop Ubuntu server that does not have Docker. Write the complete sequence of commands: installing Java, adding the repository, installing Jenkins, enabling automatic startup and retrieving the initial password.

Exercise 3. Without looking at the lesson, answer: if you delete the jenkins-trial container with docker rm -f jenkins-trial and recreate it with the same docker run command, will you keep your administrator user? Why? What would happen if you also ran docker volume rm jenkins_trial_home?

Solutions

Solution 1.

docker run -d --name jenkins-trial \
  -p 9090:8080 -p 50000:50000 \
  -v jenkins_trial_home:/var/jenkins_home \
  --restart=on-failure \
  jenkins/jenkins:lts-jdk21

docker logs jenkins-trial

The only change is the host side of -p 9090:8080: inside the container, Jenkins still listens on 8080, but you browse to http://localhost:9090. In the log, look for the block of asterisks with the password. Remember to enter http://localhost:9090/ as the Jenkins URL in the wizard.

Solution 2.

sudo apt update
sudo apt install -y fontconfig openjdk-21-jre
sudo mkdir -p /etc/apt/keyrings
sudo wget -O /etc/apt/keyrings/jenkins-keyring.asc \
  https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
echo "deb [signed-by=/etc/apt/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/" \
  | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt update
sudo apt install -y jenkins
sudo systemctl enable --now jenkins
sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Remember to check the current signing key URL on the official website.

Solution 3. Yes, you will keep the user, because the entire configuration lives in the jenkins_trial_home volume, which is not deleted when you remove the container. The new container mounts the same volume and finds the data intact. If you also delete the volume, you will lose everything (users, plugins, jobs) and Jenkins will start as if freshly installed, asking for the initial password again.

Conclusion

You now know how to install Jenkins in several ways: with Docker, with Debian/Ubuntu or RHEL/Fedora packages, with the WAR file, and on Windows or macOS. You know its requirements (Java 17 or 21, memory, disk and ports), the difference between LTS and weekly releases, how to unlock it with initialAdminPassword, how to complete the setup wizard and what JENKINS_HOME stores. Before setting up the course's final environment, you need to understand how Jenkins is organized internally: in the next lesson, Jenkins Architecture: Controller, Agents and Executors, you will see which pieces make it up and how they share the work.

© Copyright 2026. All rights reserved