简体   繁体   中英

Jenkins docker:command not found

I have installed Jenkins on my local machine which runs on MacOS High Sierra and have docker installed . I am trying to run a simple pipeline example which uses docker. I have added the following lines to pipeline :

pipeline {
    agent {
        docker 'node'
    }
    stages {
        stage("testing 123") {
            steps {
                sh 'node --version'
            }
        }
    }
}

Then from the WebGUI, I click on build now and it is failing. Console output showing the error docker: command not found . The complete error log is as follows :

Started by user Happycoder
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on Jenkins in /Users/Shared/Jenkins/Home/workspace/test
[Pipeline] {
[Pipeline] sh
[test] Running shell script
+ docker inspect -f . node
/Users/Shared/Jenkins/Home/workspace/test@tmp/durable-20ded4c0/script.sh: line 2: docker: command not found
[Pipeline] sh
[test] Running shell script
+ docker pull node
/Users/Shared/Jenkins/Home/workspace/test@tmp/durable-ebdc1549/script.sh: line 2: docker: command not found
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 127
Finished: FAILURE

Why this is happening ? In the Jenkins documentation, they are only given this syntax and doesn't mentioned about anything else.

I think the following section is not correct:

agent {
  docker 'node'
}

This command will try to launch a Docker container associated with the 'node' label.

If you want to test a declarative pipeline, you should try this syntax (if you want to build a Maven project):

agent {
  docker {
    image 'maven:3.5.0-jdk-8'
  }
}

FYI, you can find a lot of pipeline examples here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM