<p>Installed Jenkins using helm </p>

<pre><code>helm install --name jenkins -f values.yaml stable/jenkins
</code></pre>

<p>Jenkins Plugin Installed </p>

<pre><code>- kubernetes:1.12.6
- workflow-job:2.31
- workflow-aggregator:2.5
- credentials-binding:1.16
- git:3.9.3
- docker:1.1.6
</code></pre>

<p>Defined Jenkins pipeline to build docker container </p>

<pre><code>node {
    checkout scm

    def customImage = docker.build("my-image:${env.BUILD_ID}")

    customImage.inside {
        sh 'make test'
    }
}
</code></pre>

<p>Throws the error : docker not found </p>

<p><a href="https://i.stack.imgur.com/NlOI1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NlOI1.png" alt="enter image description here"></a></p>

<p>You can define agent pod with containers with required tools(docker, Maven, Helm etc) in the pipeline for that:</p>
<p>First, create agentpod.yaml with following values:</p>
<pre><code>apiVersion: v1

kind: Pod

metadata:

  labels:

    some-label: pod

spec:

  containers:

    - name: maven

      image: maven:3.3.9-jdk-8-alpine

      command:

        - cat

      tty: true

      volumeMounts:

        - name: m2

          mountPath: /root/.m2

    - name: docker

      image: docker:19.03

      command:

        - cat

      tty: true

      privileged: true

      volumeMounts:

        - name: dockersock

          mountPath: /var/run/docker.sock

  volumes:

    - name: dockersock

      hostPath:

        path: /var/run/docker.sock

    - name: m2

      hostPath:

        path: /root/.m2
</code></pre>
<p>Then configure the pipeline as:</p>
<pre><code>pipeline {
    agent {
        kubernetes {
            defaultContainer 'jnlp'
            yamlFile 'agentpod.yaml'
        }
    }
    stages {
        stage('Build') {
            steps {
                container('maven') {
                    sh 'mvn package'
                }
            }
        }
        stage('Docker Build') {
            steps {
                container('docker') {
                    sh &quot;docker build -t dockerimage .&quot;
                }
            }
        }
    }
}
</code></pre>
