DEV Community

Cover image for install Jenkins on Docker
Olawale Adepoju for AWS Community Builders

Posted on • Edited on • Originally published at dev.classmethod.jp

install Jenkins on Docker

Introduction

In today's world of DevOps, there are different tools used in achieving the CI/CD pipeline. I tried to install, configure Jenkins on Docker and build my first Job using Jenkins.

What is Jenkins

Jenkins is an essential tool for setting up Continuous Integration(CI). It helps in building the development, testing, and deployment workflow and also creates a job pipeline.

Setting up the Environment with Docker

I proceeded with installing Docker Engine. For details on how to install docker visit the official installation page at docs.docker.com
After installing docker, validate the docker environment by running

docker ps

If the above command goes through without errors, you are all set.

I installed Jenkins with minimal effort using
docker run -idt --name jenkins -v jenkins_home:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock -p 8080:8080 -p 50000:50000 jenkins/jenkins:2.346.3-slim
If you install it using the instructions above, find out the IP address and go to http://YOUR_IP_ADDRESS:8080 to access Jenkins UI.

After that, you have to select install To start/stop Jenkins with docker, use the following commands,

docker start jenkins docker stop jenkins

After the installation, you will be asked for the password.

/var/jenkins_home/secrets/initialAdminPassword

Password can be also fetched from the logs.

docker logs jenkins

Image description
Click on Select Plugins to Install when given an option.

Image description
This will let you choose the plugins to install on the next page.

Click on None to deselect all plugins

Create Admin user

Image description
successfully installed Jenkins and I can proceed with building my first job.

When you Login to Jenkins for the first time, the following is the screen you would see

NOTE: If you don't see the page you can restart Jenkins using
http://YOUR_IP_ADDRESS:8080/restart

Image description

Creating First Job
Image description

  • From Jenkins Main page, click on New Item
  • Provide a name to the project in Item Name i.e "firstJob". Check against Free Style Project.

Image description

  • Add job description. "My first Jenkins Job".
  • Skip Source Code Management and Build Triggers, and scroll down to Build configurations.
  • From "Add Build Step" select Execute Shell and provide commands to execute. #!/bin/bash echo "Hello World, this is my First Job !" sleep 10
  • Review and click on save to go to the project page.

Image description
Building Job for the First Time

  • Click on Build Now to launch a build.
  • Once the build is started, you would see the status in the Build History section.
  • Once the build is finished, click on the build number which starts with #. Clicking on the build number e.g #1 will take you to the page which shows the build stats.

Image description

I successfully built my first project using Jenkins.

Top comments (0)