📖 Scenario: You want to quickly set up Jenkins, a popular automation server, using Docker. Docker helps you run Jenkins inside a container without installing it directly on your computer.
🎯 Goal: Learn how to pull the official Jenkins Docker image, run a Jenkins container with the right settings, and verify Jenkins is running.
📋 What You'll Learn
Docker installed and running on your machine
Basic command line usage
Internet connection to download Docker images
💡 Why This Matters
🌍 Real World
Using Docker to install Jenkins lets you quickly set up a clean Jenkins environment without changing your main system. This is useful for testing or starting new projects.
💼 Career
Many DevOps roles require managing Jenkins servers. Knowing how to run Jenkins in Docker containers is a common and valuable skill.
Progress0 / 4 steps
1
Pull the official Jenkins Docker image
Open your terminal and run the command docker pull jenkins/jenkins:lts to download the latest stable Jenkins image.
Jenkins
Hint
This command downloads the Jenkins image tagged 'lts' (long-term support) from Docker Hub.
2
Create a Docker volume for Jenkins data
Run docker volume create jenkins-data to create a volume that will store Jenkins data persistently.
Jenkins
Hint
This volume keeps your Jenkins data safe even if the container stops or is removed.
3
Run the Jenkins container with volume and port mapping
Run the command docker run -d -p 8080:8080 -p 50000:50000 -v jenkins-data:/var/jenkins_home --name jenkins-server jenkins/jenkins:lts to start Jenkins in a container with data persistence and port access.
Jenkins
Hint
This command runs Jenkins in the background, maps ports for web and agent communication, and uses the volume for data.
4
Check Jenkins container status
Run docker ps and then docker logs jenkins-server to see if Jenkins is running and view its startup logs.
Jenkins
Hint
The docker ps command shows running containers. The logs should include a message like 'Jenkins is fully up and running'.
Practice
(1/5)
1. What is the main advantage of installing Jenkins using Docker?
easy
A. It only works on Windows systems
B. It requires manual setup of all dependencies
C. It disables Jenkins security features
D. It makes Jenkins installation quick and clean
Solution
Step 1: Understand Docker's role in Jenkins installation
Docker packages Jenkins and its dependencies in a container, simplifying setup.
Step 2: Identify the benefit of containerization
This containerization makes installation fast and keeps the system clean without leftover files.
Final Answer:
It makes Jenkins installation quick and clean -> Option D
Quick Check:
Docker simplifies Jenkins install = A [OK]
Hint: Docker containers isolate Jenkins for easy setup [OK]
Common Mistakes:
Thinking Docker disables Jenkins security
Assuming Docker only works on Windows
Believing manual dependency setup is needed
2. Which Docker command correctly runs Jenkins with port 8080 mapped to the host?
easy
A. docker run -p 8080 jenkins/jenkins
B. docker run -p 80:8080 jenkins/jenkins
C. docker run -p 8080:8080 jenkins/jenkins
D. docker run --port 8080:8080 jenkins/jenkins
Solution
Step 1: Recall Docker port mapping syntax
The correct syntax is '-p hostPort:containerPort'.
Step 2: Match Jenkins default port
Jenkins listens on port 8080 inside the container, so map host 8080 to container 8080.
Final Answer:
docker run -p 8080:8080 jenkins/jenkins -> Option C
Quick Check:
Port mapping uses -p host:container = A [OK]
Hint: Use -p hostPort:containerPort for port mapping [OK]
Common Mistakes:
Using wrong port order in mapping
Omitting container port
Using --port instead of -p
3. What will be the effect of running this command?
docker run -d -p 8080:8080 -v jenkins_home:/var/jenkins_home jenkins/jenkins
medium
A. Starts Jenkins but data will be lost after container stops
B. Starts Jenkins in detached mode with data persisted in volume 'jenkins_home'