Hi,

Looking at https://jenkins.io/doc/book/pipeline/docker/#dockerfile , I've
set up a repository for our project with a Dockerfile to describe the build
environment, and a simple Jenkinsfile describing the build:

    pipeline {
        agent {
            dockerfile true
        }
        stages {
            stage('Build') {
                steps {
                    sh 'make'
                }
            }
        }
    }

To make this build correctly, I had to install Docker CLI inside the
Jenkins container and give Jenkins access to control Docker.

The latter is kind of obvious, and Jenkins already had that access in order
to spawn agents as required, but I'm wondering if it makes sense to require
the Docker CLI, as I have to make sure it is present on whatever agent
builds the project, so the assertion in the documentation that it is only
Windows and MacOS agents that would have trouble running such a pipeline is
a bit bold.

I can certainly work around that, so I'm wondering what is the best
approach:

 - continue to build a derived image for Jenkins, adding the Docker CLI as
   a statically linked executable, and limit execution of Docker pipelines
   to master
 - set up a single agent that has the Docker CLI installed, give it an
   appropriate label, and use that
 - use the Docker cloud plugin to create agents on-demand that have the
   Docker CLI installed, and use these to build the pipeline (so a single
   build creates two containers).

There was a pull request[1] that eliminates the need for Docker CLI to run
a pipeline with 'agent { dockerfile true }', but it has been closed.

What would be the most sensible option to build a project like this from a
Jenkins instance that is itself running inside a Docker container?

Is there a readymade image of jenkins/jenkins:lts plus the Docker CLI, or
jenkinsci/slave:latest plus the Docker CLI, or do I have to build and
maintain these myself?

   Simon

[1] https://github.com/jenkinsci/docker-workflow-plugin/pull/195

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/20200205111953.GB6800%40psi5.com.

Reply via email to