When building Jenkins in Docker plugins fail to install

Dockerfile

FROM jenkins/jenkins:latest

ENV CURL_OPTIONS -sSfLk
ENV JENKINS_OPTS --httpPort=-1

For those who are pulling the jenkins image from dockerHub, dont pull:

docker pull jenkins

or

docker pull jenkinsci/jenkins

rather pull the latest version using:

docker pull jenkins/jenkins 

This is the latest one according to https://jenkins.io/blog/2018/12/10/the-official-Docker-image/


I recall having problems installing with that script myself. Instead, I used the following:

RUN install-plugins.sh  \
  disable-failed-job \
  disk-usage \
  greenballs \
  ...

And hopefully it doesn't make a difference for this, but I have my plugin install inside of the root portion of my Dockerfile, before dropping back to running commands as USER jenkins.


Your Dockerfile works for me, installs all plugins and builds the image successfully:

Analyzing war... 
Downloading plugins...
Downloading plugin: git from https://updates.jenkins.io/download/plugins/git/2.6.0/git.hpi
 > git depends on workflow-scm-step:1.14.2,mailer:1.17,matrix-project:1.7.1,ssh-credentials:1.12,parameterized-trigger:2.4;resolution:=optional,scm-api:1.2,token-macro:1.11;resolution:=optional,promoted-builds:2.27;resolution:=optional,credentials:2.1.4,git-client:1.21.0

Downloading plugin: workflow-scm-step from https://updates.jenkins.io/download/plugins/workflow-scm-step/latest/workflow-scm-step.hpi
...
Removing intermediate container 4f895c203944
Successfully built 31d58d1f586f  

Try docker build --no-cache in case there's an issue with one of the layers in your image cache, or set up an automated build on Docker Hub and build it on Docker's servers.