Understanding Package Managers and Installing Docker and Jenkins on Amazon Linux

Understanding Package Managers and Installing Docker and Jenkins on Amazon Linux

What is a package manager in Linux?

A package manager in Linux is a tool that automates the process of installing, updating, configuring, and removing software packages from a computer's operating system.

What is a package?

A package is a compressed archive that contains all the files and metadata needed to install, run, and manage a piece of software.

Examples of Package Managers in Linux

  • APT (Advanced Package Tool): Used by Debian-based distributions like Ubuntu.

  • Yum/DNF: Used by Red Hat-based distributions like Fedora and CentOS.

  • Pacman: Used by Arch Linux.

  • Zypper: Used by openSUSE.

  • Snap: A newer, universal package manager developed by Canonical for Ubuntu but available for other distributions as well.

Each package manager has its own command syntax and repository management system but they all serve the same basic purpose of managing software on a Linux system.

What is systemctl and systemd?

systemctl and systemd are components of modern Linux operating systems primarily used for managing system services and the boot process.

systemctl

systemctl is the command-line tool used to interact with systemd. It provides various commands to manage and control the services and the system state.

systemd

systemd is a system and service manager for Linux operating systems. It is designed to provide a suite of tools and daemons for managing system functions, and it serves as a replacement for the traditional System V init system.

Installing Docker and Jenkins on a Linux system using yum Package Manager

As I'm performing this exercise on Amazon Linux, the default software package management tool is YUM. You can use any package manager from the list above depending on your Linux distribution.

Run the command sudo su to switch to the root user (superuser) in a terminal session. This command is often used by system administrators to perform tasks that require elevated privileges.

sudo su

Part 1: Install Docker

Step 1: Update Your System

Ensure your package index is up to date.

sudo yum update -y

updated system applications

Step 2: Install Docker

Install Docker using yum.

sudo yum install docker -y

installing docker

Step 3: Check Docker Status

Check the status of the Docker service.

sudo systemctl status docker

docker service inactive

Step 4: Start Docker

Start the Docker service.

sudo systemctl start docker

docker service active

Step 5: Enable Docker to Start at Boot

Ensure Docker starts automatically when the system boots.

sudo systemctl enable docker

enabled to start at boot

Step 6: Verify Docker Installation

Check the Docker version to verify that Docker is installed correctly.

docker --version

installation verified

Part 2: Install Jenkins

Step 1: Install Amazon Corretto 11 (or a suitable version)

For Amazon Linux 2, you should use Amazon Corretto as it’s the recommended version of Java. Here’s how to install it:

sudo yum install -y java-11-amazon-corretto-devel

installed amazon-corretto-devel

Step 2: Verify Java Installation

Verify that Java is installed correctly.

java --version

installation verified

Step 3: Add the Jenkins Repository

Add the Jenkins repository using the following command:

sudo wget -O /etc/yum.repos.d/jenkins.repo \
    https://pkg.jenkins.io/redhat-stable/jenkins.repo

jenkins repo added

Step 4: Import the GPG Key

Import the key file from Jenkins-CI to enable installation from the package:

sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key

Step 5: Upgrade Packages

Upgrade all packages to make sure everything is up-to-date.

sudo yum upgrade

Step 6: Install Jenkins

Install Jenkins using yum.

sudo yum install jenkins

jenkins installed

Step 7: Start Jenkins as a Service

Start the Jenkins service.

systemctl start jenkins

Step 8: Check the Status of the Jenkins Service

Check the status of the Jenkins service.

systemctl status jenkins

jenkins status active

Step 9: Enable Jenkins to Start at Boot

Ensure Jenkins starts automatically when the system boots.

systemctl enable jenkins

jenkins service enabled