Install Jenkins using Docker

In this tutorial, I will guide you how to install Jenkins server using Docker.

First, open the Terminal on macOS and Linux or the Console on Windows, then use the “docker pull” command to download the Jenkins Image from the Docker Repository.

Here, we have two versions of Jenkins:

  • One is the LTS version (Long-term Support): This version is stable.
  • Secondly, the Weekly version is built and pushed to the Docker Repository weekly.

To download the LTS version, use the following command:

As for the Weekly version, use the following command:

In this tutorial, I will use the Weekly version.


Install Jenkins using Docker

After downloading Jenkins Image, I will now launch a container from this image.

The command to start the container is as follows:

Here, we have mapped the Jenkins home directory /var/ jenkins_home in the container with the /jenkins directory located in our current directory. This means that if you are in the /Users/Khanh directory then you have mapped the /Users/Khanh/jenkins folder on your machine to the /var/ jenkins_home directory in the container. I also mapped port 8080 of the container with port 49001 on my machine.

If you are installing Jenkins using the Docker on Windows then you can run the following command:

With the above statement, there will be no folders on your machine mapped to the Jenkins home directory in the container.

Result in my macOS as follows:

Install Jenkins using Docker

Then, if you have access to http://localhost:49001/, you will see the following output:

Install Jenkins using Docker

This is where we begin Jenkins installation.

This screen means that a password has been generated in the container’s /var/jenkins_home/secrets/initialAdminPassword file. You need to get that password to enter here. Since, I have mapped the /var/jenkins_home directory in the container with the /User/Khanh/jenkins directory, I just need to open the /User/Khanh/jenkins/secrets directory so I can get the password in the initialAdminPassword file to fill.

If you are running Docker on Windows then you can find in the console window that we are running to find this password.Install Jenkins using Docker

When done, click Continue to continue.

Install Jenkins using Docker

This screen is used to select the plugins we want to install with Jenkins. There are two options:

  • Suggest suggested plugins
  • Select plugins to install.

You can choose as you wish. For the sake of simplicity, here I will select the Install suggested plugins. Below are the plugins that Jenkins will install:

Install Jenkins using Docker

After installing the plugins, Jenkins will ask us to install the admin account:

Install Jenkins using Docker

After filling in the information, click Save and Continue button:

This window allows you to configure the Root URL of Jenkins. You can change the default value according to your needs and then click Save and Finish!

Install Jenkins using Docker

Click Start using Jenkins button to start using Jenkins.

Home page:

Add Comment