Installing Jenkins, Git & Docker  On EC2

Installing Jenkins, Git & Docker On EC2

Installing Jenkins

  • Create Ubuntu 18.04 EC2 Instance. Once you logged in to your AWS account and accessed your Ubuntu Server 18.04 LTS instance you can follow the below steps to install Jenkins.

  • Update Ubuntu Server Before installing Jenkins you have to update software packages on Ubuntu server for that use below commands.

sudo apt-get update -y
  • Add Repository Key You have to add Jenkins repository into Ubuntu server.
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -

 2022-06-01 22 42 56

  • Add Package Repository
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'

2022-06-01 22 43 14

  • Now, to update the server
sudo apt update
  • Install Jenkins Dependencies We first have to install java
sudo apt install default-jre -y

 2022-06-01 22 45 44

sudo apt install jenkins -y

 2022-06-01 22 52 13

And Jenkins installation completed you have to start Jenkins service

sudo systemctl start jenkins
sudo systemctl status jenkins

2022-06-01 22 54 48

  • Allow Jenkins Port On Ubuntu Firewall By default Ubuntu server has firewall installed and we have to allow Jenkins port 8080 from firewall so that we can access Jenkins.
sudo ufw allow 8080

 2022-06-01 22 56 40

If the Ubuntu machine firewall is not enabled, you can use the commands below to check it.

sudo ufw status

If your Ubuntu firewall is inactive use

sudo ufw allow OpenSSH 
sudo ufw enable
sudo ufw status

2022-06-01 22 58 23

2022-06-01 22 58 45

  • Setting Up Your Jenkins Now to access Jenkins from web browser you must also allow Jenkins port 8080 in AWS security group and after that you will be able to access Jenkins. So go to your AWS account-Security group and add port 8080.

  • As a last part, pen web browser and type your AWS Ec2 Ubuntu instance public IP address with 8080 port.

 2022-06-01 22 59 47

  • As per the instructions in the screenshot above, you need to get the default admin password from the given path, so on your Ubuntu machine you would issue the following command to get it.
sudo cat /var/lib/jenkins/secrets/initialAdminPassword

2022-06-01 23 00 12

  • You will get the following output and this is the default admin password to login to Jenkins copy this and use it in web browser for Jenkins login.

  • When you login to Jenkins with default admin password, it will present two options and this is recommended plugins and choose plugins to install. We recommend clicking on the suggested plugins and jenkins will take care of the plugin installations.

  • The plugins will take some time to install and once all plugins are installed Jenkins will ask you to create your Admin user account. Next, fill in your desired admin user details and set Jenkins admin credentials.

  • Click Save and Finish after setting your Jenkins access url and other information. Finally you will get a confirmation page and it will be "Jenkins Ready".

2022-06-01 23 06 51

2022-06-03 20 48 44

Installing Git

  • Update Ubuntu Server Before installing Git you have to update software packages on Ubuntu server for that use below commands.
sudo apt-get update -y
  • Install Jenkins Dependencies
sudo apt install git -y
git --version

2022-06-02 18 45 03

2022-06-02 18 45 11

What’s Docker?

Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications.

Installing Docker

Running Docker on AWS provides administrators and developers a highly reliable, cost-effective way to build, ship, and run distributed applications. Docker can be installed on many different operating systems, including Linux distributions like Ubuntu and even Mac OSX and Windows.

sudo apt-get update
sudo apt install docker.io

2022-06-02 18 45 41

service docker.io start
service docker.io status
  • Basic Commands for Docker
sudo docker info

 2022-06-02 18 46 27

sudo docker images
sudo docker ps

 2022-06-02 18 46 40

  • Run Docker Image: By default, docker pulls the images from a Docker registry called Docker Hub managed by Docker company. To confirm whether you can download the images from Docker Hub:
sudo docker run hello-world

 2022-06-02 18 47 25

In conclusion, setting up a development environment with Jenkins, Git, and Docker on an Ubuntu EC2 instance provides a powerful foundation for efficient software development and deployment. By following the outlined steps, users can seamlessly install and configure Jenkins, a robust automation server, allowing for continuous integration and delivery of code. Additionally, the installation of Git facilitates version control, enabling collaboration and tracking changes in code repositories. Furthermore, integrating Docker offers a scalable and portable solution for building, shipping, and running distributed applications across different operating systems. Overall, this comprehensive setup empowers developers and sysadmins to streamline their workflows, enhance productivity, and effectively manage software projects in a dynamic and agile manner.