Running Jenkins on Docker for Windows


A Step-by-Step Guide to Running Jenkins in Docker on Windows
Running Jenkins using Docker on Windows simplifies its installation and ensures a clean, isolated environment. Here's how I achieved this setup
Prerequisites
Docker for Desktop: Make sure Docker is installed and running on your Windows machine.
Step 1: Install Docker for Desktop and Start It
Download and install Docker for Desktop from the official site.
Launch Docker Desktop and ensure it is running.
Step 2: Run Jenkins in Docker
2.1 Download Jenkins Image
Pull the official Jenkins image using the following Docker command:
docker pull jenkins/jenkins:lts
Run command on dokcer terminal
2.2 Run Jenkins Container with Volume Attached
To persist Jenkins data (e.g., configurations, plugins, and jobs), run the container with a volume attached:
docker run -d -p 8080:8080 -p 50000:50000 --name my-jenkins -v jenkins_home:/var/jenkins_home jenkins/jenkins:lts
Run command on docker terminal
-d
: Runs the container in detached mode.-p 8080:8080
: Maps the Jenkins UI to port 8080.-p 50000:50000
: Maps the port for Jenkins agents.-v jenkins_home:/var/jenkins_home
: Attaches a named volume to store Jenkins data.
Step 3: Access Jenkins via the Browser
Open your browser and navigate to http://localhost:8080.
You'll see the Jenkins unlock screen.
Step 4: Retrieve the Administrator Password
Access the Jenkins logs or open a shell in the container:
docker exec -it my-jenkins cat /var/jenkins_home/secrets/initialAdminPassword
Run command on docker terminal
Copy the displayed password and paste it into the unlock screen.
Step 5: Install Plugins
Once unlocked, Jenkins will prompt you to install plugins.
Choose "Install suggested plugins" to set up commonly used plugins.
Add details
Click on Save and Finish - Start Jenkins
Step 6: Create and Run a Sample Job
Log in to the Jenkins dashboard.
Click on "New Item" to create a new job.
Choose "Freestyle project" and name your job.
Configure the job with a simple build step. For example, add a shell command:
echo "Hello, Jenkins!"
Follow below step
Save the job and click "Build Now" to run it.
View the build output in the "Console Output" section.
If you found my post helpful, feel free to show your support by buying me a coffee! ☕
Subscribe to my newsletter
Read articles from vikas bhaskar vooradi directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

vikas bhaskar vooradi
vikas bhaskar vooradi
In my free time, I enjoy coding, blogging, and exploring technology-related content on the internet.