Jenkins pipeline fails with docker not found message

Hello Team,

I have installed Jenkins in Docker locally on my Mac using instruction from official documentation:

All works well but pipeline fails during Build stage with following error message:

/var/jenkins_home/workspace/rst-security-jenkins-code_master@tmp/durable-8621d176/script.sh: line 1: docker: not found

script returned exit code 127

This is my Jenkinsfile:

pipeline {
  environment {
    registry = "mydockerhub/my-cicd-app"
    registryCredential = 'dockerhub'
    dockerImage = ''
  }
  agent { dockerfile true }
  // agent { 
  //   docker { 
  //     image 'python:alpine3.7'
  //     args '-p 5000:5000'
  //       } 
  // }
  stages {
    stage('Build') {
      steps {
        sh 'pip install -r requirements.txt'
        sh 'apk add libstdc++'
        sh 'python ./app.py &'
      }
    }
    stage('Test App') {
      steps {
        echo "${env.NODE_NAME}"
        sh 'pwd'
        sh 'uname -a'
        sh 'python test.py'
      }
      post {
        always {
          junit 'test-reports/*.xml'
        }
      } 
    }
    // Uncomment for SAST lab step 
    // Commented section starts
    /*
    stage('SAS Test') {
      steps {
        snykSecurity(
          snykInstallation: 'SnykV2Plugin',
          snykTokenId: 'snyktoken',
          severity: 'medium',
          failOnIssues: true)
      }
    }
    */
    // Commented section ends 
    stage('Build image') {
      steps{
        script {
          dockerImage = docker.build registry + ":$BUILD_NUMBER"
        }
      }
    }
    stage('Upload Image to Registry') {
      steps{
        script {
          docker.withRegistry( '', registryCredential ) {
            dockerImage.push()
          }
        }
      }
    }
    stage('Remove Unused docker image') {
      steps{
        sh "docker rmi $registry:$BUILD_NUMBER"
      }
    }
    // Uncomment for K8s app diployment step
    // Commented section starts
    /*
    stage('Deploy Application') {
      agent {
        kubernetes {
            cloud 'kubernetes'
          }
        }
        steps {
          container('kubectl') {
            sh """cat <<EOF | kubectl apply --validate=false -f -
apiVersion: v1
kind: Namespace
metadata:
  name: my-cicd-app
---
apiVersion: v1
kind: Service
metadata:
  name: my-service
  namespace: my-cicd-app
spec:
  selector:
    app: my-cicd-app
  ports:
    - protocol: TCP
      port: 5000
      targetPort: 5000
  type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-demo
  namespace: my-cicd-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-cicd-app
  template:
    metadata:
      labels:
        app: my-cicd-app
    spec:
      containers:
      - name: my-cicd-app
        image: $registry:$BUILD_NUMBER
        imagePullPolicy: Always
        ports:
        - containerPort: 5000
EOF"""
        }
      }
    }
   */ 
  // Commented section ends
  }
}

What could be the issue here? What’s more interesting that when I attach to jenkins (or dind) container and move into /var/jenkins_home/workspace/rst-security-jenkins-code_master directory, I am able to manually build image using docker build command…

Thanks for any comments!
Luke