Jenkins is a popular open-source automation server that helps streamline the CI/CD process. In this guide, we will cover the steps to install Jenkins using Docker.
Prerequisites
- Docker installed on your machine. If not, follow the Docker installation guide.
- Basic understanding of Docker commands.
- Internet connectivity to pull the Jenkins Docker image.
Steps to Install Jenkins
Step 1: Pull the Jenkins Docker Image
Use the following command to pull the Jenkins LTS (Long Term Support) image from Docker Hub:
docker pull jenkins/jenkins:lts
Step 2: Create a Docker Volume for Jenkins Data
Create a volume to persist Jenkins data across container restarts:
docker volume create jenkins_data
Step 3: Run the Jenkins Container
Start a Jenkins container with the following command:
docker run -d \
-p 8080:8080 \
-p 50000:50000 \
--name jenkins \
-v jenkins_data:/var/jenkins_home \
jenkins/jenkins:lts
Explanation of the options:
-d
: Runs the container in detached mode.-p 8080:8080
: Maps port 8080 on your host to port 8080 in the container (Jenkins UI).-p 50000:50000
: Maps port 50000 for Jenkins agents.-v jenkins_data:/var/jenkins_home
: Mounts thejenkins_data
volume to persist Jenkins configuration and job data.
Step 4: Access Jenkins
Once the container is running, open your browser and navigate to http://localhost:8080.
On the first launch, Jenkins will prompt for an administrator password. Retrieve it using the command:
docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword
Copy the password and paste it into the setup wizard to continue with the initial configuration.
Step 5: Complete Initial Setup
Follow the on-screen instructions to:
- Install recommended plugins.
- Create an admin user account.
- Configure Jenkins as needed.
Conclusion
Congratulations! You have successfully installed Jenkins using Docker. You can now start creating jobs and setting up your CI/CD pipelines.
0 Comments