Build and deploy Jenkins image using docker

Build and deploy Jenkins image using docker

👀To start with Jenkins continuous integration and delivery server we would be running simple Jenkins as a container and just play around with it.

Note:- We would be directly looking into Jenkins image as we had cover previous article with docker installation if you want you can refer the link

Simple running containers like Jenkins

Docker Pull command for Jenkins

docker pull jenkins/jenkins

And it should go out pull the Jenkins images and layers and run an instance of Jenkins.

If faced issue during running image and found below message then it might be due to previous unsuccessful runner setup.

💡
"Docker command not found" error typically occurs in a Jenkins Pipeline when the Jenkins agent running your pipeline does not have Docker installed or the Docker executable is not available in the system's PATH

Map a port to 8080 on docker host

💡
If you want to run and map the port 8080 to the port on the docker host just execute below command as shown.
docker run -p 8080:8080 jenkins/jenkins

Now in order to persist that data across docker container or across docker container restarts or even if you destroy docker container and run a new container and if you'd like to persist your configuration You need data to get to map volume

Create a local directory

pwd
/root

mkdir jenkins-jenkins

This will store the Jenkins data in /your/home on the host. Ensure that /your/home is accessible by the Jenkins user in container (jenkins user - uid 1000) or use -u some_other_user parameter with docker run.

You can also use a volume container:

docker run -p 8080:8080 -v /root/jenkins-jenkins:/var/jenkins_home -u root jenkins

Next, as you can see it's extracted and Jenkins is actually running and it just pull down Jenkins latest version of Jenkins and ran it

  1. This is the user Interface of Jenkins you will ask for the Admin password for setup Please copy the password from location /var/jenkins_home/secrets/initialAdminPassword

  2. Customize Jenkins select Install suggested plugins

  3. It will start with Getting Started

  4. Create First Admin User

  5. Jenkins is ready

Create a first Test Job

If you liked what you read, do follow and Any feedback for further improvement will be highly appreciated!

Thank you and Happy Learning!👏