How to Install Jenkins,Git,Docker on Amazon EC2 Instance

How to Install Jenkins,Git,Docker on Amazon EC2 Instance

In this part, I will show how to install and launch Jenkins,Git,Docker on a AWS EC2 instance.

Let's get start with Jenkins

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 -

Image description

  • Add Package Repository

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

Image description

  • Now, to update the server

sudo apt update

  • Install Jenkins Dependencies We first have to install java

sudo apt install default-jre -y

Image description

sudo apt install jenkins -y

Image description

  • And Jenkins installation completed you have to start Jenkins service

sudo systemctl start jenkins sudo systemctl status jenkins

Image description

  • 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

Image description

  • 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

Image description

Image description

  • 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.

Image description

  • 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

Image description

  • 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.

Image description

  • 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.

Image description

  • 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".

Image description

Image description

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

Image description

Image description

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

Image description

service docker.io start service docker.io status

  • Basic Commands for Docker

sudo docker info

Image description

sudo docker images sudo docker ps

Image description

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

Image description

Did you find this article valuable?

Support Sourav Dhiman by becoming a sponsor. Any amount is appreciated!