Skip to content

Jenkins Installation Using Docker (Server Setup)

Jenkins Logo

This guide explains how to install and run Jenkins using Docker on an Ubuntu server. This setup allows Jenkins to build and deploy Docker-based applications.


Prerequisites

  • Ubuntu server (20.04 / 22.04 recommended)
  • Root or sudo access
  • Internet connection

Step 1: Install Docker

Update system packages:

sudo apt update

Install Docker:

sudo apt install -y docker.io

Enable and start Docker:

sudo systemctl enable docker
sudo systemctl start docker

Verify Docker installation:

docker --version

Step 2: Run Jenkins Using Docker

Run Jenkins container with required volumes and ports:

docker run -d \
  --name jenkins \
  -p 8080:8080 \
  -p 50000:50000 \
  -v jenkins_home:/var/jenkins_home \
  -v /var/run/docker.sock:/var/run/docker.sock \
  jenkins/jenkins:lts

Explanation

Option Description
-p 8080:8080 Jenkins Web UI
-p 50000:50000 Jenkins agent communication
jenkins_home Persistent Jenkins data
docker.sock Allows Jenkins to run Docker commands

Step 3: Get Jenkins Initial Admin Password

Run:

docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword

Copy the password.


Step 4: Access Jenkins UI

Open browser:

http://SERVER_IP:8080
  • Paste admin password
  • Click Install Suggested Plugins
  • Create Admin User
  • Finish setup

Step 5: Verify Jenkins Container

Check running containers:

docker ps

You should see:

jenkins   jenkins/jenkins:lts   Up

Step 6: Verify Docker Access Inside Jenkins

docker exec -it jenkins docker ps

If it lists containers → Jenkins can deploy Docker apps.


Common Commands

Stop Jenkins

docker stop jenkins

Start Jenkins

docker start jenkins

Restart Jenkins

docker restart jenkins

Remove Jenkins Container (Data Safe)

docker rm jenkins

Warning

Jenkins data is stored in jenkins_home Docker volume and will NOT be lost.


Jenkins Data Location

Docker Volume:

jenkins_home

Used for:

  • Jobs
  • Plugins
  • Credentials
  • Pipeline configs

Next Steps

  • Install Git & Pipeline plugins
  • Create a Jenkins Pipeline Job
  • Add a Jenkinsfile to your project
  • Automate deployments

Jenkins Installed Successfully

Your Jenkins server is now ready to run CI/CD pipelines using Docker.