๐Ÿ’พThananjhayan
โ† Back to notes

Running Jenkins (with Docker)

July 17, 2025

The quickest way to get a Jenkins server running for the exam.

Run Jenkins in Docker

docker run -d --name jenkins -p 8080:8080 -p 50000:50000 \
  -v jenkins_home:/var/jenkins_home \
  jenkins/jenkins:lts
docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword
  • Install suggested plugins โ†’ create the admin user.

Jenkins needs Docker to build images

If Jenkins runs in a container, it can't build images unless it can reach the Docker daemon. Two options:

  • Install Jenkins directly on the machine that has Docker (simplest), or
  • Mount the host Docker socket into the Jenkins container:
docker run -d --name jenkins -p 8080:8080 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v jenkins_home:/var/jenkins_home \
  jenkins/jenkins:lts

Then install the Docker CLI inside the Jenkins container. This is the classic "Docker-in-Jenkins" setup โ€” good to mention in the viva.

The Jenkins agent must have Docker installed and permission to use it โ€” add the jenkins user to the docker group, or mount docker.sock as above.

Next: [[jenkins-docker-hub-credentials]] and [[jenkins-pipeline-job]].

๐Ÿ’ฌ Comments