I'm using Jkube maven plugin to generate a Docker image via a Jenkins pipeline on AWS EC2 instance under Ubuntu.
When pipeline executes mvn clean install k8s:build
I'm getting this error :
[ERROR] Failed to execute goal org.eclipse.jkube:kubernetes-maven-plugin:1.3.0:build (default-cli) on project social-carpooling-frontend: Execution default-cli of goal org.eclipse.jkube:kubernetes-maven-plugin:1.3.0:build failed: No <dockerHost> given, no DOCKER_HOST environment variable, no read/writable '/var/run/docker.sock' or '//./pipe/docker_engine' and no external provider like Docker machine configured -> [Help 1]
And this is the Jenkins pipeline :
pipeline {
agent any
stages {
stage('Docker Check Stage') {
steps {
sh '/home/bitnami/downloads/apache-maven-3.8.1/bin/mvn clean install k8s:build -Premote'
}
}
}
}
When I log using ssh to this machine and execute docker -v
it says Docker version 20.10.0, build 7287ab3
So Docker is really installed and daemon is started, but when I trigger it via maven it seems not to find it ! Any ideas ?
The problem was due to the user who's running maven command which doesn't have access to docker.sock
The solution is to modify the read/write permission on docker.sock this way :