Thursday, August 31, 2023

INSTALLATION OF JENKINS ON DOCKER




Installation of Jenkins on Docker refers to the process of setting up and running Jenkins, an automation server, within a Docker container. Docker allows for the easy deployment and management of applications by encapsulating them in lightweight, isolated containers.

In the context of Jenkins, installing it on Docker involves the following steps:

  1. Installing Docker: Docker must be installed on the host machine or server where Jenkins will run. This typically involves downloading and installing the appropriate Docker package for the operating system.
  2. Creating a Docker Volume: Jenkins requires persistent storage for its configuration and data. A Docker volume is created to store this data, ensuring that it is preserved even if the Jenkins container is removed or replaced.
  3. Running the Jenkins Container: A Jenkins container is launched using the official Jenkins Docker image (jenkins/jenkins). This image contains the necessary components and dependencies to run Jenkins. The container is started with specified port mappings to access the Jenkins web interface and agent communication ports. The previously created Docker volume is mounted to the container, providing persistent storage.
  4. Accessing the Jenkins Web Interface: Once the Jenkins container is running, the Jenkins web interface can be accessed through a web browser by navigating to the appropriate URL. The specific URL will depend on the host machine’s IP address or hostname and the port mapping configured during container launch.
  5. Unlocking Jenkins: Upon the first access to the Jenkins web interface, an initial administrator password is required to unlock Jenkins. This password is retrieved from within the running Jenkins container using a Docker command. After unlocking Jenkins with the provided password, the setup process can continue.
  6. Configuring Jenkins: The Jenkins web interface guides the user through the initial setup, allowing for the customization of installation options and plugin selection. This step ensures that Jenkins is configured to meet the user’s specific requirements and integrates with the desired tools and technologies.
  7. Creating an Administrator User: As part of the configuration process, an administrator user account is created for managing Jenkins. This account provides privileged access to configure and administer the Jenkins server.

By following these steps, Jenkins is successfully installed and running within a Docker container. This setup allows for the easy management, scalability, and portability of Jenkins, while leveraging the benefits of Docker’s containerization technology.

Create a separate directory for the project, and configure the Docker compose file:

Compose file in VS CODE:

Save in Vim docker-compose.yml file

Pull image from Docker Hub: weekly release:

https://hub.docker.com/r/jenkinsci/jenkins/

–>Important::Also, you may use the following docker hub image for your container: simply replace the image with Jenkins:Jenkins

Create a volume directory (jenkins_vol) in the same folder (docker_projects): give full access to the jenkins_vol directory:

root@ip-172-31-27-212:/home/ubuntu/docker# chmod 777 jenkins_vol/

setup Jenkins using the following command:

>>docker-compose up -d

Docker Installation verification:

>>root@ip-172-31-27-212:/home/ubuntu/docker_projects# docker images

>>root@ip-172-31-27-212:/home/ubuntu/docker_projects# docker ps

root@ip-172-31-27-212:/home/ubuntu/docker_projects# systemctl status docker

Jenkins login password:

root@ip-172-31-27-212:/home/ubuntu/docker_projects# docker logs b4055cf1fc3e

Jenkins Installation on Docker Container:

ALL DONE>>>

===================================

Have a Great Weekend!!

No comments:

Post a Comment