1. Running Jenkins server on Docker container

In this post, I want to go through Jenkins’s installation and setup process on a Docker container. Sure there are a bunch of resources where you may find a similar introduction, still, I decided to make a simple and straightforward one.

Image for post
Image for post

Requirements

  • Basic Docker knowledge
  • Docker installed and running
  • Virtualbox or Another machine to add as Slave (need wenn we create Slave)

I will use it as host machine Debian-buster, but steps are the same on Windows and macOS.

Firstly let me explain briefly Jenkins and how it works.

Jenkins is an open-source automation tool that enables developers to reliably build, test, and deploy their software. Jenkins is one of the most powerful CI/CD tools. Jenkins works master-slave concept for distributed build option. Master node coordinating and providing the GUI and API endpoints, and the Agents are designed to perform the work. Following words are synonym: Worker = Slave = Agent

  1. Step: Getting official Jenkins image and start the Jenkins server

Official Jenkins image is hosted on docker hub

So before we move forward let me explain command above

  • docker run → starting container
  • -d detached mode. You will not see any logs
  • -p 8080:8080 → exporting port for external access
  • v → is volume, where all Jenkins files will be saved. If you don’t run with volume, when you kill your container or container die somehow, your configuration and setup will be lost. For more information about docker volume see

jenkins_volume → directory on your localhost

:/var/jenkins_home → directory on docker container

  • — name my_jenkins is optional container name but it is a good practice to giving a name to the container
  • jenkins/jenkins is the image name

So now if go on browser and type localhost:8080, you should see the pic below:

Image for post
Image for post

You need the password to login the Jenkins. Jenkins provides an initial password by starting the server. This can be found:

  • Checking logs → docker logs [container name] or
  • interaction with container and see under given path /var/jenkins_home/secrets/initialAdminPassword

I will do with the second way

Then click continue and next step install preferred plugins. It will take some minutes. After plugins are installed you should see Admin panel where you may set your name and password.

Image for post
Image for post
Admin Panel

Set your username, password and then save it to continue. The next screen should be also straightforward simply finish and ready to use Jenkins!

Image for post
Image for post
Home

PS: Next post will be about how to set Jenkins-Slave on a running server

Computer Science And DevOps things :)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store