I have created GKE cluster and install Jenkins on that cluster. Now i am running pipeline, i have Jenkinsfile created which is used to build DockerImage but when i am running the pipeline, it throws exception that Docker not found
1) Created GKE Cluster 2) Installed Jenkins 3) Added Docker hub credentials 4) Added access key for gitlab
Jenkinsfile:
stage('Build Docker Image') { when { branch 'master' } steps { script { echo 'Before docker run' sh 'docker --version' app = docker.build("sarab321/test-pipeline") echo 'docker run successfully' } } }
Please see the exception below
apiVersion: "v1" kind: "Pod" metadata: annotations: {} labels: jenkins: "slave" jenkins/cd-jenkins-slave: "true" name: "default-d7qdb" spec: containers: - args: - "59c323186a77b4be015362977ec64e4838001b6d77c0f372bec7cda7cf93f9b2" - "default-d7qdb" env: - name: "JENKINS_SECRET" value: "59c323186a77b4be015362977ec64e4838001b6d77c0f372bec7cda7cf93f9b2" - name: "JENKINS_TUNNEL" value: "cd-jenkins-agent:50000" - name: "JENKINS_AGENT_NAME" value: "default-d7qdb" - name: "JENKINS_NAME" value: "default-d7qdb" - name: "JENKINS_URL" value: "http://cd-jenkins.default.svc.cluster.local:8080" image: "jenkins/jnlp-slave:3.27-1" imagePullPolicy: "IfNotPresent" name: "jnlp" resources: limits: memory: "512Mi" cpu: "1" requests: memory: "256Mi" cpu: "500m" securityContext: privileged: false tty: false volumeMounts: - mountPath: "/var/run/docker.sock" name: "volume-0" readOnly: false - mountPath: "/home/jenkins" name: "workspace-volume" readOnly: false workingDir: "/home/jenkins" nodeSelector: {} restartPolicy: "Never" serviceAccount: "default" volumes: - hostPath: path: "/var/run/docker.sock" name: "volume-0" - emptyDir: medium: "" name: "workspace-volume"
- docker version /home/jenkins/workspace/TestPipeline_master@tmp/durable-5dd73d2b/script.sh: 1: /home/jenkins/workspace/TestPipeline_master@tmp/durable-5dd73d2b/script.sh: docker: not found