Jenkins failing to build docker image. script.sh docker not found

9/20/2021

I have a jenkins instance running on a EKS cluster and I'm trying to setup Jenkins to build my images and push to my ECR but it's not working because docker seems to be missing.

Here's my Jenkinsfile

pipeline {
    agent any
    stages {
        stage("build"){
            steps {
                sh('docker -v')
                sh('docker login --username AWS --password-stdin dkr.ecr.eu-north-1.amazonaws.com')
                sh('docker build -t dkr.ecr.eu-north-1.amazonaws.com/test .')
                echo('building app')
            }
        }

        stage('test'){
            steps {
                sh('docker tag test dkr.ecr.eu-north-1.amazonaws.com/test')
                echo('testing app')
            }
        }

        stage('deploy'){
            steps {
                sh('docker push dkr.ecr.eu-north-1.amazonaws.com/test')
                echo('deploying app')
            }
        }
    }
}

But I'm running into an error of script.sh: 1: docker: not found.

What am I missing, do I need to install Docker on Jenkins, and if so, how do I do that?

-- Gurkmeja101
amazon-ecr
amazon-eks
jenkins
jenkins-pipeline
kubernetes

0 Answers