Installing Jenkins using Docker Compose - PerfectionGeeks

How to install Jenkins using Docker Compose?

June 15, 2022 04:15 PM

Installing Jenkins using Docker Compose

What is Jenkins's?

Jenkins is an open-source tool for automating work related to the Continuous Integration and Continuous Delivery methodology. It is a device that supports the work of programmers in the continued building, testing, and even automatic building of tasks in test and production environments.

What is Docker composed of?

Docker is the software utilized to operate applications in a virtualized environment. Because of that, we can handle the application in a particular container that is independent of the working system. In this way, we can schedule different environments using other devices without fear of conflicts between versions of libraries and frameworks.

Docker Compose is an instrument that allows you to determine and work with Docker-based applications. This tool enables you to specify full environments consisting of numerous containers using YAML files. As an instance of such an environment, I can mention the www application, which consists of a container having a web server and a second container having a database for this application.

Needed tools

To begin installing Jenkins, make sure you have the needed tools. Please note that the installation will be based on Docker Compose, so please make sure you have it downloaded.

To confirm that Docker Compose is available, you can run this command.

If you do not own this tool yet, I recommend you install it according to the instructions on this page:

https://docs.Docker.com/compose/install/

For Mac OS and Windows, Docker Compose is included in Docker Desktop. For Linux, this package must be installed individually.

Note: All the commands in this manual are run from the Linux console, which indicates that they won’t operate from the standard Windows console. Here I suggest utilizing the Windows Subsystem for Linux (WSL), which can be installed on Windows 10.

Make a configuration for Docker Compose

At the very start, I recommend making a particular directory where we will perform on the project and an additional directory where we will store Jenkins data (/Jenkins home).

Now make the Docker-compose.yml file and copy the following content to it:

The above configuration will allow us to make a container with the latest version of Jenkins (LTS). The most essential parts of this configuration are:

Picture – specifies the image we want to

At which ports do we want products from the container to be available? In our case, it will be ports 8080 (www) and 50000 (API).

container_name: our container's name

Volumes—these are the virtual volumes utilized by the container. In our case, we have a jenkins_home directory, which is on our system, and an extra two volumes that authorize us to utilize Docker from.

Begin filling the container

The container is established with one easy command:

After operating the Docker command, it will download the Jenkins picture from the servers and handle the container. In my opinion, it looked like this:

Before we proceed to the browser, we must copy the administrator password that was generated automatically when the server first started. Wedo it with the command.

Jenkins’s first run

Once we have the password, we can go to the browser. In the URL address, type http://localhost:8080/ and the following page should appear.

Here, in the Administrator password area, enter the password that we just copied. After putting in the password, we go to the next page: Continue.

In the next stage, we have the choice to select the add-ons that we would like to install on our server. Here, I recommend using the default list of plugins by choosing the Install suggested plugins choice.

After a few points, Jenkins should install the needed add-ons.

In the following step, we will create an administrator account. After delivering the necessary information, click "save" and continue.

The server address details will appear on the next screen. We go to the default address here and move on (Save and Finish).

The necessary setup is done!

After going to the following page, we should see this screen.

Congratulations, you just installed Jenkins!

We get the first job

The foremost tasks will be based on a straightforward Hello World project in Java: https://github.com/Coveros/helloworld. To be able to make a project, you must configure Jenkins to use the Maven tool.

To do this, move to the Jenkins configuration panel (Manage Jenkins): On the following screen, we go to Global Tool Configuration.

On the next screen, go to the Maven area and click Add Maven. Here we give the title of the Maven configuration (just maven) and exit the rest of the ruins. Save the settings.

After configuration, we go back to the primary screen (connect on Dashboard) and perform our foremost task.

On the next screen, we describe our job. We provide its name and select the type of freestyle project.

On the latest screen, go to the Source Code Management section. There, select Git and paste the address https://github.com/Coveros/helloworld.gi t in the Repository URL field. This is the URL address of our Git repository on GitHub.

In this way, we specified the source of our assignment.

Then we go to the Build section, where we will explain our jobs related to making the project. Click here to add the build step and choose to invoke top-level Maven targets. Here we choose the earlier described maven configuration. Additionally, we describe the purpose of our objectives: a clean package.

Now let’s add the second stage to our building procedure: Run the shell and type java -cp target/HelloWorld-1.1.jar com.covers. demo. Hello World. HelloWorld. This command will begin our application and display the result in the console.

We now keep our configuration and run our job: Build Now

After a few moments, the assignment should begin and finish successfully (green color).

Here, it is worth taking a look at what the entire installation procedure looked like. We can do this by tapping on link # 1. And then tap on Console Output

On the new page, we should see the log of the whole job.

In the log, we should see details about the correct installation of the application and the development of the test application call.

Stop the container

A previously run Docker-compose command made the container run in the background. If you like to stop the container, just run the following command in the Jenkins directory.

What are some of the top company advantages of operating Jenkins in a Docker container?

Businesses choose Jenkins in a Docker container when they like most of the composition of the server under control. Most organizations keep Jenkins in the pipeline when they like the power to run the server locally on any device while testing with new components and configurations.

Installing Jenkins with Docker Composer will assist companies with:

  • Easy deployment and scalability
  • increased density with more workload handling capacity.
  • More rapid delivery of applications
  • Flexible management of the environment

Summary

In this tutorial, I demonstrated to you how to simply begin to start a Jenkins server. Importantly, the server handles data in a container but keeps its data in a directory open on your computer or server. This means that you can efficiently archive this data or even share it with another computer or server. In this path, the data will not be forfeited even if the container is deleted. If you have faced any problems installing Jenkins using Docker Compose, you can directly consult with a PerfectionGeeks Technologies expert.

Book an Appointment

Perfectiongeeks Technology is ready to provide the right solution according to your needs

img

img

img

India Standard Time

Book an Appointment to know how Perfectiongeeks Technology smartbuild can benefit your Business.

Select a Date & Time


Message Image

Stop wasting time and money on digital solution Let's talk with us

Launching

Testing

Maintenance

Stage 5 - Testing and Quality Assurance
Stage 6 - Deployment
Stage 7 - Maintenance and Updates

Contact US!

India india

Plot No- 309-310, Phase IV, Udyog Vihar, Sector 18, Gurugram, Haryana 122022

8920947884

USA USA

1968 S. Coast Hwy, Laguna Beach, CA 92651, United States

9176282062

Singapore singapore

10 Anson Road, #33-01, International Plaza, Singapore, Singapore 079903

Contact US!

India india

Plot 378-379, Udyog Vihar Phase 4 Rd, near nokia building, Electronic City, Sector 19, Gurugram, Haryana 122015

8920947884

USA USA

1968 S. Coast Hwy, Laguna Beach, CA 92651, United States

9176282062

Singapore singapore

10 Anson Road, #33-01, International Plaza, Singapore, Singapore 079903