0

I am trying to use docker agent in Jenkinsfile:

pipeline {
    agent {
        docker {
            image "openjdk:jdk-alpine"
        }
    }

    stages {
        stage("Hello") {
            steps {
                sh "echo 'Hello'"
            }
        }
    }
}

But I have got:

/var/jenkins_home/workspace/tesler@tmp/durable-7aaf5de1/script.sh: 1: /var/jenkins_home/workspace/tesler@tmp/durable-7aaf5de1/script.sh: docker: not found
[Pipeline] isUnix
[Pipeline] sh
+ docker pull openjdk:jdk-alpine
/var/jenkins_home/workspace/tesler@tmp/durable-af6a5d64/script.sh: 1: /var/jenkins_home/workspace/tesler@tmp/durable-af6a5d64/script.sh: docker: not found

I am testing this with Jenkins casc. I need docker so I have copy its definition to casc file from https://github.com/jenkinsci/configuration-as-code-plugin/tree/master/demos/docker It is not working. In jenkins dockers lists there is an error: docker servers list with error

I hope that when I will fix docker error Jenkinsfile will work too. What is wrong?

Kuba Wenta
  • 580
  • 1
  • 5
  • 25
  • 1
    did you install docker in jenkins server ? or you have already installed docker via docker plugin ? – Thanh Nguyen Van Oct 21 '20 at 10:29
  • I have installed docker-plugin. Does it mean I have docker running? I am new to Jenkins. – Kuba Wenta Oct 21 '20 at 10:45
  • 1
    Install docker in your server and add the jenkins user in docker group. Then, it will work – Sourav Oct 21 '20 at 10:48
  • I have just installed docker (dind) next to jenkins container. I think it is next step because now in list of dockers I can see: Name Active Hosts docker (0) But still pipeline fail with script.sh: docker: not found – Kuba Wenta Oct 22 '20 at 08:45

0 Answers0