Jenkins unable to use docker agent in pipeline

Hello !

I am running Jenkins in Docker container but getting the below error while running a pipeline job. The below pipeline snippet checks if maven is being used or not, it throws below error message.

Installed Plugins are,

  1. Docker plugin
  2. Docker pipeline

Additionally, I also configured docker on Jenkins UI, under tools section. Can someone suggest over this ?

Pipeline snippet:

pipeline {
agent {
docker {
image ‘maven:latest’
}
}
stages {
stage (‘Check’) {
steps {
sh ‘mvn -v’
}
}
}
}

Seems docker is not in the path of the user running jenkins. the user also needs to be in the docker group so it can successfully run docker commands

2 Likes