Install docker and Jenkins on Digital Ocean droplet
Introduction
Jenkins is an open-source automation server that automates the repetitive technical tasks involved in the continuous integration and delivery of software. Jenkins is Java-based and can be installed from Ubuntu packages or by downloading and running its web application archive (WAR) file — a collection of files that make up a complete web application to run on a server.
In this tutorial, you will install Jenkins by adding its Debian package repository, and using that repository to install the package with apt
.
Installation via commands
# Install Java 8
sudo add-apt-repository ppa:webupd8team/java
sudo apt install openjdk-8-jre -ywget -q -O — https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
sudo apt-add-repository “deb https://pkg.jenkins.io/debian-stable binary/”sudo apt-get update
# Install Jenkins
sudo apt install jenkins -y
# Start and expose Jenkins
#if 8080 is used by other software you can change default port of jenkins using vi /etc/sysconfig/jenkins#Inside the configuration file find the flowing line ‘JENKINS_PORT=”8080"’ and replace the port which you want to use.
sudo systemctl start jenkins
sudo systemctl status jenkins
sudo ufw allow <your assigned port> or 8080 #8080 if port has not changed sudo ufw status
Setting up Jenkins
To set up our installation, we’ll visit Jenkins on its default port, 8080
, using the server domain name or IP address: http://ip_address_or_domain_name:<assigned port>
We should see “Unlock Jenkins” screen, which displays the location of the initial password
# Install Docker
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable”
sudo apt update
apt-cache policy docker-ce
sudo apt install docker-ce -y
sudo systemctl status docker
# Give the right permissions to Jenkins on Docker
usermod -aG docker jenkins
usermod -aG root jenkins
chmod 777 /var/run/docker.sock
# Get password for initial setupecho ‘Jenkins initial admin password is:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword