# Installing Docker and Jenkins using Package Managers on Ubuntu and CentOS

Installing Docker and Jenkins on your Ubuntu or CentOS system is a straightforward process thanks to the package managers available on these platforms. In this article, we will guide you through the steps to install Docker and Jenkins using package managers on Ubuntu and CentOS.

1. Installing Docker on Ubuntu:
    

Step 1: Update package lists

```bash
sudo apt update
```

Step 2: Install Docker

```bash
sudo apt install docker.io
```

Step 3: Start and enable Docker service

```bash
sudo systemctl start docker
sudo systemctl enable docker
```

1. Installing Docker on CentOS:
    

Step 1: Add the Docker repository

```bash
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
```

Step 2: Install Docker

```bash
sudo yum install docker-ce docker-ce-cli containerd.io
```

Step 3: Start and enable Docker service

```bash
sudo systemctl start docker
sudo systemctl enable docker
```

1. Installing Java:
    

Java is required to run Jenkins. Follow these steps to install Java using package managers on Ubuntu and CentOS:

For Ubuntu:

```bash
sudo apt update
sudo apt install default-jdk
```

For CentOS:

```bash
sudo yum update
sudo yum install java-1.8.0-openjdk
```

Step 3: Installing Jenkins:

Once Java is installed, we can proceed with installing Jenkins using package managers. Here's how to do it on Ubuntu and CentOS:  
  
For Ubuntu:

```bash
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt update
sudo apt install jenkins
```

For CentOS:

```bash
sudo yum install -y wget
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
sudo yum install -y jenkins
```

1. Starting and Accessing Jenkins:
    

After the installation, start the Jenkins service and enable it to run on system boot:

For Ubuntu:

```bash
sudo systemctl start jenkins
sudo systemctl enable jenkins
```

For CentOS:

```bash
sudo systemctl start jenkins
sudo systemctl enable jenkins
```

To access the Jenkins web interface, open a web browser and enter [`http://localhost:8080`](http://localhost:8080) or [`http://your-server-ip:8080`](http://your-server-ip:8080). Jenkins will prompt you to enter the initial administrator password, which can be found at `/var/lib/jenkins/secrets/initialAdminPassword`. Follow the instructions to complete the setup and create an admin user.  

It was challenge for day 7. I hope I kept it simple to follow. Looking forward to next challenge.

Happy learning.
