Friday, June 9, 2023

Install Jenkins in Azure VM using Docker | How to Install Jenkins in Azure VM using Docker Compose on Ubuntu 22.0.4 | Install Jenkins using Docker-Compose

Jenkins is an open source continuous integration/continuous delivery and deployment (CI/CD) automation software DevOps tool written in the Java programming language. It is used to implement CI/CD workflows, called pipelines.

How to setup Jenkins using Docker Compose?

Jenkins is continuous integration server. It is open source and Java based tool. Jenkins can be setup using Docker Compose with less manual steps.

What is Docker Compose?
Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration. Since Docker Compose lets you configure related containers in a single YAML file, you get the same Infrastructure-as-Code abilities as Kubernetes. But they come in a simpler system that’s more suited to smaller applications that don’t need Kubernetes’ resiliency and scaling.
The purpose of docker-compose is to function as docker cli but to issue multiple commands much more quickly. To make use of docker-compose, you need to encode the commands you were running before into a docker-compose.yml file
Run docker-compose up and Compose starts and runs your entire app.


Change Host Name to Jenkins
sudo hostnamectl set-hostname Jenkins

Perform system update
sudo apt update

Install Docker-Compose
sudo apt install docker-compose -y

Create docker-compose.yml
this yml has all configuration for installing Jenkins.
sudo vi docker-compose.yml 

(Copy the below code high-lighted in yellow color)
version: '3'
    image: jenkins/jenkins:lts
    restart: always
    privileged: true
    user: root
      - 8080:8080
      - 50000:50000
    container_name: jenkins
      - /home/ubuntu/jenkins_compose/jenkins_configuration:/var/jenkins_home
      - /var/run/docker.sock:/var/run/docker.sock

Save the file by entering :wq!

Execute Docker compose command:
sudo docker-compose up -d 

Make sure Jenkins is up and running by checking the logs
sudo docker-compose logs --follow

Once you see the message, that's it. Jenkins is been installed successfully. press control C and enter.
Now access Jenkins UI by going to browser and enter public dns name with port 8080
Now to go to browser --> http://your_jenkins_publicdns_name:8080/

You can get the Admin password from above command as well.

Enter Admin Password

Enter the password and Click on continue.
Then click on install suggested plug-ins. 
Also create user name and password.
enter everything as admin. at least user name as admin password as admin
Click on Save and Finish. Click on start using Jenkins. Now you should see a screen like below:

That's it. You have setup Jenkins successfully using Docker Compose.

To Clean Up Resources

sudo docker compose down

This should stop the Jenkins container that is running.

Click here to learn how to create a FreeStyle job in Jenkins to automate Build and Deployment of Java Web App.
Click here to learn how to create a Pipeline job in Jenkins to automate Build and Deployment of Java Web App.

Watch Steps in YouTube channel:

1 comment:

  1. Thank you sir for this video.
    I have an assignment to do which is "Provision EKS cluster using terraform.EKS Deployment for application on AWS using Helm charts and monitor the application cloudwatch." . I have provisioned an EKS cluster using terraform with 2 worker nodes and deployed a simple calculator application written in spring boot using helm chart with the help of your tutorial. Now the third part of my assignment is to monitor the application using cloudwatch. Please give me a solution for this and tell me what can I use. I got to know about container insights in cloudwatch but I was asked to explore other options. Please provide me the best solution and a tutorial or a blog or steps on how to enable monitoring of my application using amazon cloudwatch.
    Thanks and Regards


Automate Azure App Service setup using Ansible and Azure DevOps pipeline | How to integrate Ansible with Azure DevOps | How to Create WebApp in Azure Cloud using Ansible

Ansible is an open-source, configuration management tool that automates cloud provisioning, configuration management, and application deploy...