How to install Jenkins inside Docker container
As we all know Jenkins is an open-source software for build, test and deploy whereas Docker is a platform for running applications in an isolated environment called as ‘containers.
Well Jenkins can be downloaded either locally or by installing on any server. If you want to install Jenkins, you can download from here.
But for this post we will use Jenkins docker image. Let’s start:
Step 1: We will use Docker Desktop for our local system, so first install Docker Desktop from here. Make sure you have to add “C:\Program Files\Docker\Docker\resources\bin” this path in PATH section in your environment variables.
Step 2: Now launch the docker desktop and open either command prompt/Windows PowerShell to run this command:
docker pull jenkins
or
docker run --name myjenkins -p 8080:8080 -p 50000:50000 -v /var/jenkins_home jenkins/jenkins:lts-jdk17
Here -p 8080:8080
maps port 8080 on the host to port 8080 in the container (for the Jenkins web interface).
-p 50000:50000
maps port 50000 on the host to port 50000 in the container (for Jenkins agent communication with Jenkins master).
The above command will pull the Jenkins image from Docker Hub.
Now when you do “docker ps” command, you will get this output.
Step 3: After installation, there is an initial password will be there. Make sure you copied as it will require further.
Step 4: Now Jenkins run on “http://localhost:8080/” open this on any web browser.
Now under the “Administrator Password” enter the copied password.
Step 5: Click on “Installed suggested plugins”.
Step 6: Now it will install the required Plugins.
Step 7: After plugins installation, it will ask you to enter your new admin username and password.
Step 8: By default, Jenkins runs on “http://localhost:8080/” so recommendation is not changing the by default URL.
Step 9: Now setup is complete, and Jenkins is ready!
Conclusion:
Installing Jenkins using docker is an efficient way to use as it saves memory and easy to install. It is easier to manage and deployment your processes.
Happy Automating!