Would you like to use Jenkins in your machine and don't want to follow the traditional installation process ? If your say YES - then follow along this brief article !
Prerequisites:
This article assumes you have some idea of what docker is and how to use it. The pre-requisites to get started are:
Docker
running in your machine
If you are completely new to docker, I would highly recommend starting from here.
Installation Steps:
- Create a folder called build and add a
Dockerfile
in it with content as below.
# build/Dockerfile
FROM jenkins/jenkins:lts-alpine
USER root
RUN apk add docker
- Create a
docker-compose.yml
as below:
#docker-compose.yml
version: "3.8"
services:
jenkins:
build: build/
ports:
- 8090:8080
volumes:
- "jenkins.data:/var/jenkins_home"
- "/var/run/docker.sock:/var/run/docker.sock"
volumes:
jenkins.data:
- Run the below command to start the service:
docker-compose up -d
- Open the browser at:
localhost:8090
- We get a jenkins screens as below for the initial administrator password
- Get the password from:
docker-compose exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword
- After entering the password from above step, Jenkins shows the plugin selection screen.
After the successful installation of the required plugins you will be redirected to Jenkins Dashboard page. You may create an admin user if required.
That's it. You can use Jenkins now to create and run jobs as long as the container is running :)