Skip to content

Docker With Jenkins#

What Is The Jenkins?#

  • Jenkins is a self-contained, open source automation server which can be used to automate all sorts of tasks related to building, testing, and delivering or deploying software.
  • Jenkins can be installed through native system packages, Docker, or even run standalone by any machine with a Java Runtime Environment (JRE) installed.
  • More information

Create Jenkins Server With Docker#

  • Let's create a docker-compose.yml then add some scripts as below
docker-compose.yml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
version: '3.7'

services:
  jenkins:
    #using image from DockerHub
    image: jenkins/jenkins
    #enable privileged mode
    privileged: true
    #privileged mode with root user
    user: root
    ports:
    - 8081:8080
    - 50000:50000
    container_name: jenkins
    volumes:
    - ./jenkins:/var/jenkins_home
    - ./docker:/usr/local/bin/docker

volumes:
  jenkins:
  docker:
  • You can see we config the docker-compose with privileged mode. So what is the privileged mode?

  • Docker privileged mode grants a Docker container root capabilities to all devices on the host system. Running a container in privileged mode gives it the capabilities of its

 #zoom

  • Then we create 2 folders named jenkins and docker to sync the data from docker to our real machine.

 #zoom

Testing#

  • Now, Let use docker-compose up to start the server. Then you can go to localhost:8081 to access Jenkins and setup username/password and some plugins.
  • When server is started up for the first time, you can get the credential in the log of jenkins container to bypass the first authentication step.

 #zoom

  • Then you have to wait for installing recommended plugins of jenkins.
  • After that you should create the first admin user.

 #zoom

  • After setting up, now you can start using jenkins.

 #zoom

References#