Jenkins pipeline exception - Getting docker not found

5/2/2019

I am running Jenkins service on azure kubernetes services, and I have simple pipeline script to build my demo angular project..

pipeline {
 agent any 
 stages {
 stage(‘Build’) {
        steps {
            checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'mygithub', url: 'https://github.com/prabaharanit/docker-angular-example']]])
        }
    }

 stage('Fetch dependencies') {
  agent {
    docker 'circleci/node:9.3-stretch-browsers'
  }
  steps {
    sh 'yarn'
    stash includes: 'node_modules/', name: 'node_modules'
  }
}
}
}

when I build my pipeline i am getting below error,

/var/jenkins_home/workspace/worklist-pipeline@2@tmp/durable-ec84fb4d/script.sh: docker: not found.

how to make Jenkins to use my host docker container for builds.. this is for testing purpose and I want to use my host docker to run the build and create images.. I have tried adding docker form global tool configurations.. but it doesn't work.

-- pappu_kutty
azure-aks
azure-kubernetes
docker
jenkins

1 Answer

5/2/2019

In order to use your Jenkins host docker engine. Remove the below agent statement from the pipeline -

  agent {
    docker 'circleci/node:9.3-stretch-browsers'
  }

PS - You can use agent { label 'master' } in the stage whenever you want to use the Jenkins host machine.

-- vivekyad4v
Source: StackOverflow