Install Jenkins on Linux step-by-step Using Docker Compose

Suresh yadav
Cypik
Published in
4 min readApr 5, 2024

Install Jenkins in a Docker Container using Docker Compose on Linux

Cypik.com

Prerequisites

  • Amazon Linux Machine with a minimum of 2GB RAM.
  • Needs to open 8080 port on EC2 Security Group.

Steps to install Jenkins

  • Install Docker and Docker Compose on the Machine.
  • Create Volume for Jenkins.
  • Create docker-compose file.
  • Run the docker-compose file.

Install Docker.io

# Install Docker using apt package manager
sudo apt-get install docker.io

# Start the Docker service
sudo service docker start

# Add the user "suresh" to the "docker" group, granting them permission to run Docker commands without sudo
sudo usermod -a -G docker suresh

# Enable Docker to start automatically at boot time
sudo systemctl enable docker

# Start the Docker service using systemd
sudo systemctl start docker

# Display information about the Docker installation and its configuration
docker info

Install Docker Compose

#downloading docker compose
sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
#changing the permissions
sudo chmod +x /usr/local/bin/docker-compose
#Restart the Docker service
sudo service docker restart

Create Volume for Jenkins

mkdir -p /home/suresh/jenkins_data/jenkins_home

Create a Docker Compose file

vim docker-compose.yml

Paste the code below and save the file

version: '3'

services:
jenkins:
container_name: jenkins
image: jenkins/jenkins:lts-jdk11
restart: unless-stopped
ports:
- "8080:8080"
volumes:
- "/home/suresh/jenkins_data/jenkins_home:/var/jenkins_home"

Run the Docker Compose file

docker-compose up -d

Docker Commands to view containers

View containers

Now the Jenkins was Successfully installed. We can access Jenkins by opening the Jenkins URL on the browser http://server-ip-address:8080.

unlocking Jenkins

You can use the following commands to find and display the initial admin password:

cat /var/jenkins_home/secrets/initialAdminPassword

Creating the first administrator user?

you can create your first administrator user.

  1. When the Create First Admin User page appears, specify the details for your administrator user in the respective fields and click Save and Finish.
  2. When the Jenkins is ready page appears, click Start using Jenkins.
    Notes:
    -
    This page may indicate Jenkins is almost ready! instead and if so, click Restart.
    - If the page does not automatically refresh after a minute, use your web browser to refresh the page manually.
  3. If required, login to Jenkins with the credentials of the user you just created and you are ready to start using Jenkins!
Install suggested plugins

Installation of Jenkins plugins has been started. It will take a couple of minutes to complete the installation.

Create the First Admin User account for Jenkins Portal.

On the ‘Instance Configuration’ page, it will ask you to set the default URL for Jenkins. Click on Save and Finish to proceed.

Jenkins installation has been completed successfully. Now, you can work on Jenkins by clicking on Start using Jenkins.

Jenkins’s dashboard is displayed below.

Jenkins dashboard

Jenkins was installed and configured successfully.

You can also check another alternative using To Install Jenkins without Docker:

Enjoy it! 🍻 That’s It; we are done...

For seamless Cloud Management incorporating DevOps as the core of the methodology, reach out to us at info@cypik.com

Cypik

About the author:

My name is Suresh Yadav, and I am an experienced Linux enthusiast and DevOps engineer. I’m passionate about automating and streamlining development processes, and currently, I work as a DevOps Engineer at Cypik. I specialize in cloud technologies with a focus on Google Cloud Platform (GCP).

--

--

Suresh yadav
Cypik
Writer for

DevOps Engineer || GCP || Aws || Jenkins || Networking || Terraform || Github || Mysql || Ansible || Linux || Docker