<p>I am configuring jenkins + jenkins agents in kubernetes using this guide:</p>
<p><a href="https://akomljen.com/set-up-a-jenkins-ci-cd-pipeline-with-kubernetes/" rel="nofollow noreferrer">https://akomljen.com/set-up-a-jenkins-ci-cd-pipeline-with-kubernetes/</a></p>
<p>which gives the below example of a jenkins pipeline using multiple/different containers for different stages:</p>
<pre><code>def label = &quot;worker-${UUID.randomUUID().toString()}&quot;

podTemplate(label: label, containers: [
  containerTemplate(name: 'gradle', image: 'gradle:4.5.1-jdk9', command: 'cat', ttyEnabled: true),
  containerTemplate(name: 'docker', image: 'docker', command: 'cat', ttyEnabled: true),
  containerTemplate(name: 'kubectl', image: 'lachlanevenson/k8s-kubectl:v1.8.8', command: 'cat', ttyEnabled: true),
  containerTemplate(name: 'helm', image: 'lachlanevenson/k8s-helm:latest', command: 'cat', ttyEnabled: true)
],
volumes: [
  hostPathVolume(mountPath: '/home/gradle/.gradle', hostPath: '/tmp/jenkins/.gradle'),
  hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock')
]) {
  node(label) {
    def myRepo = checkout scm
    def gitCommit = myRepo.GIT_COMMIT
    def gitBranch = myRepo.GIT_BRANCH
    def shortGitCommit = &quot;${gitCommit[0..10]}&quot;
    def previousGitCommit = sh(script: &quot;git rev-parse ${gitCommit}~&quot;, returnStdout: true)
 
    stage('Test') {
      try {
        container('gradle') {
          sh &quot;&quot;&quot;
            pwd
            echo &quot;GIT_BRANCH=${gitBranch}&quot; &gt;&gt; /etc/environment
            echo &quot;GIT_COMMIT=${gitCommit}&quot; &gt;&gt; /etc/environment
            gradle test
            &quot;&quot;&quot;
        }
      }
      catch (exc) {
        println &quot;Failed to test - ${currentBuild.fullDisplayName}&quot;
        throw(exc)
      }
    }
    stage('Build') {
      container('gradle') {
        sh &quot;gradle build&quot;
      }
    }
    stage('Create Docker images') {
      container('docker') {
        withCredentials([[$class: 'UsernamePasswordMultiBinding',
          credentialsId: 'dockerhub',
          usernameVariable: 'DOCKER_HUB_USER',
          passwordVariable: 'DOCKER_HUB_PASSWORD']]) {
          sh &quot;&quot;&quot;
            docker login -u ${DOCKER_HUB_USER} -p ${DOCKER_HUB_PASSWORD}
            docker build -t namespace/my-image:${gitCommit} .
            docker push namespace/my-image:${gitCommit}
            &quot;&quot;&quot;
        }
      }
    }
    stage('Run kubectl') {
      container('kubectl') {
        sh &quot;kubectl get pods&quot;
      }
    }
    stage('Run helm') {
      container('helm') {
        sh &quot;helm list&quot;
      }
    }
  }
}
</code></pre>
<p>But why would you bother with this level of granularity? E.g. why not just have one container that have all you need, jnlp, helm, kubectl, java etc. and use that for all your stages?</p>
<p>I know from a purist perspective its good to keep container/images as small as possible but if that's the only argument I would rather have it one container  + not having to bother my end users (developers writing jenkinsfiles) with picking the right container - they should not have to worry about stuff at this level instead they you need to be able to get an agent and that's it.</p>
<p>Or am I missing some <strong>functional</strong> reason for this multiple container setup?</p>

u123
<p>Using one single image to handle all process is funtionally feasible, but it adds burden to your <strong>operation</strong>.</p>
<p>We don't always find an image that fulfills all our needs, i.e. desired tools with desired version. Most likely, you are going to build one.</p>
<p>To achieve this, you need to build docker images for different arch (amd/arm) and maintain/use a docker registry to store your built image, this process can be time consuming as your image gets more complicated. <strong>More importantly, it is very likely that some of your tools 'favour' some particular linus distro, you will find it difficult and <em>not always functionally ok.</em></strong></p>
<p>Imagine you need to use a newer version of docker image in on of your pipeline's step, you will have you repeat the whole process of building and uploading images. Alternatively, you only need to change the image version in your pipeline, it minimises your operation effort.</p>
