Installing Docker and Jenkins on Ubuntu and CentOS

Installing Docker and Jenkins on Ubuntu and CentOS

Introduction

Docker and Jenkins are essential tools in modern software development and deployment pipelines. Docker allows you to containerize applications, making them portable and easy to manage, while Jenkins is a popular automation server for building, testing, and deploying code. In this article, we will guide you through the process of installing Docker and Jenkins on both Ubuntu and CentOS Linux distributions.

Installing Docker On Ubuntu:

1. Update Package Lists:

```

sudo apt update

```

2. Install Required Packages:

```

sudo apt install -y apt-transport-https ca-certificates curl software-properties-common

```

3. Add Docker Repository Key:

```

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

```

4. Add Docker Repository:

```

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

```

5. Install Docker:

```

sudo apt update

sudo apt install -y docker-ce docker-ce-cli containerd.io

```

6. Start and Enable Docker Service:

```

sudo systemctl start docker

sudo systemctl enable docker

```

#### On CentOS:

1. Update Package Lists:

```

sudo yum update

```

2. Install Required Packages:

```

sudo yum install -y yum-utils device-mapper-persistent-data lvm2

```

3. Add Docker Repository:

```

sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

```

4. Install Docker:

```

sudo yum install -y docker-ce docker-ce-cli containerd.io

```

5. Start and Enable Docker Service:

```

sudo systemctl start docker

sudo systemctl enable docker

```

Installing Jenkins

1. Install Java (required for Jenkins):

```

sudo apt install openjdk-11-jre (On Ubuntu)

sudo yum install java-11-openjdk (On CentOS)

```

2. Add Jenkins Repository Key (for Ubuntu):

```

wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -

```

3. Add Jenkins Repository (for Ubuntu):

```

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

```

4. Install Jenkins (for Ubuntu):

```

sudo apt update

sudo apt install -y jenkins

```

5. Install Jenkins (for CentOS):

```

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

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

sudo yum install -y jenkins

```

6. Start and Enable Jenkins Service:

```

sudo systemctl start jenkins

sudo systemctl enable jenkins

```

7. Unlock Jenkins: Access Jenkins through a web browser by entering `http://<your_server_ip>:8080`. You'll be prompted to enter an initial admin password. Retrieve this password from `/var/lib/jenkins/secrets/initialAdminPassword` (for Ubuntu) or `/var/lib/jenkins/secrets/initialAdminPassword` (for CentOS). Follow the on-screen instructions to complete the setup.

Conclusion

You've successfully installed Docker and Jenkins on both Ubuntu and CentOS. These tools are now ready to help you manage containers and automate your development and deployment processes. Remember to secure your Jenkins installation and customize it according to your project's needs. Happy coding!