Jenkins docker not found

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Jenkins docker not found

adrian lee
Hi all, 

I am trying to use docker with Jenkins. 

I installed it as a global toolconfiguration call myDocker. 

I then tried to write a pipeline script as below

```
pipeline {
   agent any
    
   // set path
   stages {
      stage ('set docker path'){
          steps{
              script{
                  def dockerHome = tool 'myDocker'
                  env.PATH = "${dockerHome}/bin:${env.PATH}"
              }
            sh 'docker ps'
          }
      }

      //delete
      stage('node') {
        agent {
            docker { image 'node:7-alpine' }
        }
        steps {
            sh 'node --version'
        }
      }


   }
}
```

however, it keeps throwing me an error

```
+ docker ps
/var/lib/jenkins/workspace/openFaaS_getdata@tmp/durable-270f2b11/script.sh: line 1: docker: command not found

```

I tried referencing other posts on stack overflow but could not find what is wrong. 

Any help?

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/2c4833ee-1210-4815-9b82-e4efb6f1f95f%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Jenkins docker not found

Simon Richter
Hi,

On Wed, Feb 05, 2020 at 07:44:57AM -0800, adrian lee wrote:

> however, it keeps throwing me an error
>
> ```
> + docker ps
> /var/lib/jenkins/workspace/openFaaS_getdata@tmp/durable-270f2b11/script.sh:
> line 1: docker: command not found
>
> ```

> I tried referencing other posts on stack overflow but could not find what
> is wrong.

That is the same problem I'm having: the plugin responsible for handling
"agent { docker ... }" and "agent { dockerfile ... }" uses the Docker CLI
instead of the Docker API, so the "docker" program must be in the search
path.

There was a proposed fix[1] for that, but it seems that is dead.

What I'm doing now, until someone makes a better suggestion, is to build a
derived Jenkins container that adds the "docker" CLI tool to the image
using wget, and limit all builds to run on master so the tool is available.

Since the actual build happens inside a fresh container anyway, the only
annoying thing about this is that the build counts against master's
executors.

   Simon

[1] https://github.com/jenkinsci/docker-workflow-plugin/pull/195

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/20200205171925.GA8541%40psi5.com.