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/nullawkecho 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/nullawkInstall Java and Jenkins
sudo apt-get update
sudo apt install openjdk-17-jre -y
sudo apt install jenkins -ymipsasmStep 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.repoawksudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.keyawkInstall Dependencies and Jenkins
sudo yum upgrade -y
sudo yum install java-17-openjdk -y
sudo yum install jenkins -y
sudo systemctl daemon-reloadmipsasmStep 4: Enable and Start Jenkins
sudo systemctl enable jenkins
sudo systemctl start jenkinsnsisCheck status:
sudo systemctl status jenkinsebnfStep 5: (Production Requirement) Docker Access for Jenkins
If Jenkins needs to build Docker images, add Jenkins to the Docker group:
sudo usermod -aG docker jenkinsebnfπ Restart Jenkins after this step:
sudo systemctl restart jenkinsebnfIf Docker is not installed, refer to: Getting Started with Docker
Step 6: Access Jenkins UI
Open your browser:
Local server:
http://localhost:8080awkRemote server / EC2:
http://<server-ip>:8080awkπ 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/initialAdminPasswordawkCopy the password and paste it into the Jenkins UI.
Step 8: Complete Jenkins Setup
Click Install Suggested Plugins
Create an Admin User
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/jenkinsawk π 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 π)