Skip to main content

How to Install Jenkins using Docker ?

· 2 min read
Rahul Vijayakumar
DevOps Enthusiast with Expertise in Server Management & Operations

Install Jenkins Using Docker

In this article, we will take a look at how to install or deploy Jenkins using Docker. First Install Docker if you haven’t already. You can use the below instructions to install docker in Ubuntu.

Open your terminal and run the following.

# Add Docker's official GPG key
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# Add the repository to Apt sources:
echo \
"deb [arch=$($(dpkg --print-architecture)) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

Now that docker is installed, we can install Jenkins using Docker.

Run the following commands in the terminal

sudo docker network create jenkins

After you have run the above command run the following command.

sudo docker run \  
--name rvk-jenkins-docker \
--restart=on-failure \
--detach \
--network jenkins \
--env DOCKER_HOST=tcp://docker:2376 \
--env DOCKER_CERT_PATH=/certs/client \
--env DOCKER_TLS_VERIFY=1 \
--publish 8080:8080 \
--publish 50000:50000 \
--volume jenkins-data:/var/jenkins_home \
--volume jenkins-docker-certs:/certs/client:ro ghcr.io/rahulvk007/rvk-docker-jenkins:latest

Now visit localhost:8080 if you are installing on your local machine or your_server_ip:8080 if you are installing on a server.

You will see the Jenkins configuration screen and you can follow the on screen instructions to setup Jenkins.