5

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.

Kwhitejr
  • 2,206
  • 5
  • 29
  • 49

3 Answers3

6

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)

Khoa
  • 1,738
  • 1
  • 14
  • 21
0

I would check the user who is running the jenkins process and make sure they are part of the docker group.

  • this would AFAIK only help with access to the docker socket, not to the executable. – StephenKing Jul 31 '18 at 07:57
  • Unfortunately the Docker documentation on setting up groups for MacOS links to the general Getting Started docs, which itself links to the the Linux documentation, which does not in fact work for MacOS >_< https://docs.docker.com/get-started/#test-docker-version – Kwhitejr Jul 31 '18 at 23:26
  • there is no docker group anymore. See: https://forums.docker.com/t/no-more-docker-group/9123. Also: the staff group does not work either. sudo is required – Thomas Stubbe Feb 06 '19 at 17:19
0

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.

Amit
  • 387
  • 3
  • 14