9 min read

Install and Set Up Jenkins for Production on Linux and Docker

Nasrul Hasan
Nasrul Hasan
Nasrul Hasan
Cover Image for Install and Set Up Jenkins for Production on Linux and Docker

Install and Set Up Jenkins for Production

Jenkins is one of the most popular open-source CI/CD automation tools used to build, test, and deploy applications. It plays a critical role in modern DevOps pipelines by automating repetitive tasks and enabling faster, reliable software delivery.

In this guide, you’ll learn how to install and set up Jenkins for production on:

  • Ubuntu

  • Red Hat–based systems

  • Docker (optional approach)

We’ll focus on a server-based Jenkins installation, suitable for real-world CI/CD use cases.


Prerequisites

Before installing Jenkins, ensure you have:

  • A Linux server (EC2, VM, or bare metal)

  • Root or sudo access

  • Open port 8080 in firewall or security group

  • Internet access


Jenkins Installation Overview

There are multiple ways to install Jenkins:

  • Native package installation (recommended for production)

  • Docker container

  • Kubernetes (advanced use case)

πŸ‘‰ In this blog, we’ll install Jenkins directly on a Linux server for better control and stability.


Step 1: Spin Up a Linux Server

Create an Ubuntu or Red Hat EC2 instance (or any Linux VM).

πŸ’‘ You can also use an on-prem VM or bare-metal server.


Step 2: Install Jenkins on Ubuntu

Add Jenkins Repository and Key

curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
  /usr/share/keyrings/jenkins-keyring.asc > /dev/null
awk
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
awk

Install Java and Jenkins

sudo apt-get update
sudo apt install openjdk-17-jre -y
sudo apt install jenkins -y
mipsasm

Step 3: Install Jenkins on Red Hat / Amazon Linux

Add Jenkins Repository

sudo wget -O /etc/yum.repos.d/jenkins.repo \
https://pkg.jenkins.io/redhat-stable/jenkins.repo
awk
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
awk

Install Dependencies and Jenkins

sudo yum upgrade -y
sudo yum install java-17-openjdk -y
sudo yum install jenkins -y
sudo systemctl daemon-reload
mipsasm

Step 4: Enable and Start Jenkins

sudo systemctl enable jenkins
sudo systemctl start jenkins
nsis

Check status:

sudo systemctl status jenkins
ebnf

Step 5: (Production Requirement) Docker Access for Jenkins

If Jenkins needs to build Docker images, add Jenkins to the Docker group:

sudo usermod -aG docker jenkins
ebnf

πŸ” Restart Jenkins after this step:

sudo systemctl restart jenkins
ebnf

If Docker is not installed, refer to: Getting Started with Docker


Step 6: Access Jenkins UI

Open your browser:

  • Local server:

http://localhost:8080
awk
  • Remote server / EC2:

http://<server-ip>:8080
awk

πŸ“Œ Important: Make sure port 8080 is open in:

  • EC2 Security Group

  • Firewall (UFW / iptables)


Step 7: Unlock Jenkins (First-Time Setup)

Jenkins will ask for an initial admin password.

Run:

cat /var/lib/jenkins/secrets/initialAdminPassword
awk

Copy the password and paste it into the Jenkins UI.


Step 8: Complete Jenkins Setup

  1. Click Install Suggested Plugins

  2. Create an Admin User

  3. Save and continue

πŸŽ‰ Jenkins is now successfully installed!


Basic Production Best Practices

Before using Jenkins in production:

  • βœ… Use non-root Jenkins user

  • πŸ” Secure Jenkins with strong admin credentials

  • πŸ”„ Enable regular backups (
    /var/lib/jenkins
    awk
    )
  • 🌐 Place Jenkins behind Nginx reverse proxy (HTTPS)

  • πŸ”‘ Use credentials store instead of hardcoding secrets


What’s Next?

Now that Jenkins is ready, you can:

  • Create CI/CD pipelines

  • Integrate GitHub or GitLab

  • Automate Docker builds

  • Deploy to AWS, Kubernetes, or EC2

πŸ‘‰ Next Blog: Jenkins Production Hardening: Best Practices for Secure and Reliable CI/CD (Coming Soon πŸš€)