Reputation: 2306
When running jobs from Jenkinsfile with Pipeline syntax and a Docker agent, the pipeline fails with "Docker: command not found." I understand this to mean that either (1) Docker is not installed; or (2) Jenkins is not pointing to the correct Docker installation path. My situation is very similar to this issue: Docker command not found in local Jenkins multi branch pipeline . Jenkins is installed on MacOS and running off of localhost:8080
. Docker is also installed (v18.06.0-ce-mac70)./
That user's solution included a switch from pipeline
declarative syntax to node
scripted syntax. However I want to resolve the issue while retaining the declarative syntax.
Jenkinsfile
#!groovy
pipeline {
agent {
docker {
image 'node:7-alpine'
}
}
stages {
stage('Unit') {
steps {
sh 'node -v'
sh 'npm -v'
}
}
}
}
Error message
docker inspect -f . node:7-alpine
docker: command not found
docker pull node:7-alpine
docker: command not found
In Jenkins Global Tool Configuration, for Docker installations I tried both (1) install automatically (from docker.com); and (2) local installation with installation root /usr/local/
.
All of the relevant plugins appears to be installed as well.
Upvotes: 5
Views: 11042
Reputation: 1948
I solved this problem here: https://stackoverflow.com/a/58688536/8160903
(Add Docker's path to Homebrew Jenkins plist /usr/local/Cellar/jenkins-lts/2.176.3/homebrew.mxcl.jenkins-lts.plist)
Upvotes: 8
Reputation: 397
You can try adding the full path of docker
executable on your machine to Jenkins at Manage Jenkins > Global Tool Configuration
.
I've seen it happen sometimes that the user which has started Jenkins doesn't have the executable's location on $PATH
.
Upvotes: 0
Reputation: 23
I would check the user who is running the jenkins process and make sure they are part of the docker group.
Upvotes: 0