Table of Contents

Jenkins - Docker Installation

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

/var/run/docker.sock

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:

/var/run/docker.sock

Login

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:

docker exec -it jenkins bash
which java
# /opt/java/openjdk
cd $ANT_HOME
ant -f fetch.xml -Ddest=system

Blue ocean

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