Installing Jenkins using Docker
A step by step guide on how to install Jenkins using Docker.
17 December, 2021
2
2
0
Contributors
Jenkins is one of the most popular automation servers that provides support for building and deploying pipelines and make the development process fully automatic.
In this article, we will see how to use Docker to install and run Jenkins in a container. To understand what Docker is, visit my Docker vs Kubernetes article.
Installing Jenkins using Docker

For installing and running Docker, we are going to use Katacode. It is an interactive learning and training platform for software engineers. It provides real environments for learning new technologies right in the browser.
Before we begn with the installation process, let us check if docker is installed in the Katacode environment by running the docker version command. In case the docker is not installed, we run the apt install docker command.
docker version

After checking the docker version, we run the Jenkins image in detached mode -d and bind it to port 8080. Along with this, we also open a port at 50000 that is used by the master and the worker nodes Jenkins to communicate with each other. Then we specify a docker named volume -v my-jenkins-home:/var/jenkins_home. This named volume helps in persisting the Jenkins state in the environment file system.
Let’s check if the container is up and running by typing the docker ps command.
docker ps

We can see that our container is up and running.
Now we head over to port 8080 by clicking the plus symbol on the right side of the terminal and selecting the “Select port to view on the Host 1” option.
selecting the port 8080 option

This opens a new browser tab where we specify the port that we want to display. In our case, we type 8080 and click the Display button.

On clicking the display button, we get redirected to the Jenkins login page where we are needed to enter the admin password.
Jenkins login page

To obtain the password, we have to be inside the Jenkins’ container. For that, we have to run the exec command in interactive mode.
Then we read the data from the file in the secrets folder using the cat command.

We enter the obtained password in the Administrator password section and press continue.
Unlocking Jenkins by entering the password

This takes us to the next section where we are asked to customize Jenkins by installing the plugins. In our case, we install the suggested plugins by selecting the Install suggested plugins option.
Customizing Jenkins

On selecting this option, Jenkins start installing all the recommended plugins.
plugin installation

Once the installation of the plugins is complete, we are asked to create a user by entering a username and password. After entering the credentials, we press save and continue.
Create user page


Then we press Start using Jenkins.
Start using Jenkins page

This brings us to the Welcome page of Jenkins, where we manage and build the pipelines, add plugins, etc for different jobs as per user needs.
Jenkins Welcome Page

This is how we install and run Jenkins in Docker.
For more such 💻DevOps content, follow 🚀 Dipankar Medhi.
docker
devops
developer
cicd
jenkins