Jenkins - Docker Installation

Card Puncher Data Processing

About

Jenkins installation on Docker

Steps

Create a container

Create an container and run it from the Community edition image

Volume

Docker - Volume Mount

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

Bind

Docker - Bind mount on Windows mounting JENKINS_HOME to a local directory (in our example to D:\jenkins_home)

# The jenkins home
mkdir D:\jenkins_home
# Just to send data
mkdir D:\backup
cd /D D:\jenkins_home
docker run -d ^
   --name jenkins ^
   -p 8081:8080 ^
   -p 50000:50000 ^
   -v %cd%:/var/jenkins_home ^
   -v d:\backup:/backup ^
   -v /var/run/docker.sock:/var/run/docker.sock ^
   --env JAVA_OPTS="-Dmail.smtp.starttls.enable=true" ^
   --restart always ^
   jenkins/jenkins:lts

where:

  • the JAVA_OPTS is to enable TLS
  • restart is to restart the container on the start of docker

Login

  • Admin Password can be seen in the log or at JENKINS_HOME/secrets/initialAdminPassword
docker logs jenkins
Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:

7ab9314d864540bcb474d35fe56943eb

This may also be found at: /var/jenkins_home/secrets/initialAdminPassword

Jenkins Unlock

Reverse proxy

HTTP - Gateway (Reverse Proxy)

Tools and configuration

Install the tools

Manage Jenkins > Global Tools Configuration:

  • Java - Add the local JDK. On docker, to get the path
docker exec -it jenkins bash
which java
# /opt/java/openjdk
cd $ANT_HOME
ant -f fetch.xml -Ddest=system
  • Gradle
  • Mail Configuration

Blue ocean

  • Blue Ocean version (The new UI)
docker run \
  --name jenkins \
  -u root \
  -p 8080:8080 \
  -v jenkins-data:/var/jenkins_home \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v "$HOME":/home \
  jenkinsci/blueocean

Documentation





Discover More
Card Puncher Data Processing
Jenkins - Docker Plugin

docker plugin Doc ! Build Step: Docker Workflow Plugin: ...
Which Nohup
Jenkins - Installation / Configuration

Choice: Docker Windows Local next-executions You may get this error: You need to add the docker variable to the user running Jenkins...



Share this page:
Follow us:
Task Runner