DEV Community

Kipchirchir Langat Emmanuel
Kipchirchir Langat Emmanuel

Posted on • Originally published at blog.kipchirchirlangat.com on

Set up Jenkins server on a digital ocean droplet.

This article will go through the steps needed to set up a Jenkins instance on a digital ocean droplet

What is Jenkins?

Jenkins is an open-source automation server that helps development teams to automate repetitive tasks in CI/CD

Let's now head to set up our Jenkins server.

1. Register for a digital ocean account here

2. Create a droplet with the following specs.

  • An image - Ubuntu: the Lts tag
  • Plan - 4GB 2 AMD CPUs
  • Datacenter region - (preferably one close to your location)
  • Authentication method - (ssh keys) and copy your public key to Digital Ocean. follow this link to create ssh keys.

3. Configure firewall rules to open ports 22 and 8080 that our Jenkin server will use.

Click on the newly created droplet and navigate to the networking tab.

Screenshot from 2022-08-25 14-23-51.png

Ensure that ports 22 and 8080 are open to receive requests.

Enter fullscreen mode Exit fullscreen mode

Screenshot from 2022-08-25 14-25-59.png

4. Install docker and run Jenkin as a docker container.

4.1 ssh into the droplet by using the command

         ```


            ssh root@YOUR_IP


#### 4.2. Update the server by using the command.



Enter fullscreen mode Exit fullscreen mode

apt update




#### 4.3. Install recommended upgrades.



Enter fullscreen mode Exit fullscreen mode

apt upgrade -y




#### 4.4. Install docker runtime engine.



Enter fullscreen mode Exit fullscreen mode

apt install docker.io -y




## 5. Run Jenkins as a docker container using the following command



Enter fullscreen mode Exit fullscreen mode

docker run -p 8080:8080 -p 50000:50000 -d \
-v jenkins_home:/var/jenkins_home \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(which docker):/usr/bin/docker jenkins/jenkins:lts




### 6. Access the Jenkins server on the web using the server's public IP as shown below



Enter fullscreen mode Exit fullscreen mode

134.xxx.xx.xxx:8080




After a successful installation of Jenkins in the Docker container, you should see a screen similar to the one below that will prompt you for an administrator password



Enter fullscreen mode Exit fullscreen mode

use this command to get the initialAdminPassword

cat /var/lib/docker/volumes/jenkins_home/_data/secrets/initialAdminPassword




copy the password and login into Jenkins. We can now create our first Jenkins user.

![Screenshot from 2022-08-25 15-07-43.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1661429412236/lz0Kc6M0H.png)

We have now successfully installed Jenkins.

In our next article, we shall go through how to deploy a Django application to an ec2 instance using the Jenkins server we have set up.
Enter fullscreen mode Exit fullscreen mode

Top comments (0)