I am running a Jenkins on local and I created a pipeline that uses a Docker container as an agent for the build stage. However, I am encountering the following error during the Build and Test stage.
process apparently never started in /var/lib/jenkins/workspace/ci-cd-ec2@2@tmp/durable-72cb4860
(running Jenkins temporarily with -D.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)
I have created a jenkins user here is the terminal response
uid=135(jenkins) gid=142(jenkins) groups=142(jenkins),998(docker)
Here is the Jenkins pipeline
pipeline {
agent {
docker {
// Use a Docker image that has Maven, Java 21, and (optionally) Docker CLI installed.
image 'jelastic/maven:3.9.5-openjdk-21'
// Mount the host Docker socket so the container can run docker commands.
args '--user root -v /var/run/docker.sock:/var/run/docker.sock'
}
}
environment {
// Define your Docker image name (update with your Docker Hub username and image name)
DOCKER_IMAGE = "rajputuser/docker-shivam-imz:latest"
// Set the SonarQube URL. Update this IP if needed.
SONAR_URL = "http://172.17.0.2:9000"
}
stages {
stage('Build and Test') {
steps {
// List files (for debugging) and run Maven to clean, compile, test, and package your app.
sh 'ls -ltr'
sh 'mvn clean package'
}
}
stage('SonarQube Analysis') {
steps {
// Run SonarQube analysis using Maven.
// Credentials for SonarQube are injected via SONAR_TOKEN.
withCredentials([string(credentialsId: 'sonarqube', variable: 'SONAR_TOKEN')]) {
sh 'mvn sonar:sonar -Dsonar.login=$SONAR_TOKEN -Dsonar.host.url=${SONAR_URL}'
echo 'SonarQube analysis completed successfully!'
}
}
}
stage('Build Docker Image') {
agent {
docker {
image 'abhishekf5/maven-abhishek-docker-agent:v1'
args '--user root --privileged -v /var/run/docker.sock:/var/run/docker.sock' // mount Docker socket to access the host's Docker daemon
}
}
steps {
// Build the Docker image using the Dockerfile in the workspace.
sh 'docker build -t $DOCKER_IMAGE .'
}
}
stage('Push Docker Image') {
agent {
docker {
image 'abhishekf5/maven-abhishek-docker-agent:v1'
args '--user root --privileged -v /var/run/docker.sock:/var/run/docker.sock' // mount Docker socket to access the host's Docker daemon
}
}
steps {
// Log in to Docker Hub and push the built image.
withCredentials([usernamePassword(credentialsId: 'dockerhub', usernameVariable: 'DOCKER_USER', passwordVariable: 'DOCKER_PASS')]) {
sh 'echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin'
sh 'docker push $DOCKER_IMAGE'
}
}
}
stage('Deploy to EC2') {
agent {
docker {
image 'abhishekf5/maven-abhishek-docker-agent:v1'
args '--user root --privileged -v /var/run/docker.sock:/var/run/docker.sock' // mount Docker socket to access the host's Docker daemon
}
}
steps {
// Deploy to an EC2 instance via SSH.
withCredentials([sshUserPrivateKey(credentialsId: '27727626-31a0-4d61-ab9d-18353c0d6b89', keyFileVariable: 'EC2_KEY', usernameVariable: 'EC2_USER')]) {
sh '''
ssh -o StrictHostKeyChecking=no -i $EC2_KEY [email protected] <<EOF
docker pull $DOCKER_IMAGE
docker stop springboot-app || true
docker rm springboot-app || true
docker run -d --name springboot-app -p 8081:8081 $DOCKER_IMAGE
EOF
'''
}
}
}
}
post {
always {
cleanWs() // Clean the workspace after the pipeline completes.
}
}
}
Verified that Jenkins has permission to access /var/run/docker.sock. Checked that the Docker image jelastic/maven:3.9.5-openjdk-21 is pulled correctly. Ensured Jenkins has sufficient resources (CPU, RAM, disk space). Tried adding -D.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true, but no additional logs appeared. Checked if running mvn clean package manually inside the same container works (it does). Restarted Jenkins and Docker service, but the issue persists.
I am running a Jenkins on local and I created a pipeline that uses a Docker container as an agent for the build stage. However, I am encountering the following error during the Build and Test stage.
process apparently never started in /var/lib/jenkins/workspace/ci-cd-ec2@2@tmp/durable-72cb4860
(running Jenkins temporarily with -D.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)
I have created a jenkins user here is the terminal response
uid=135(jenkins) gid=142(jenkins) groups=142(jenkins),998(docker)
Here is the Jenkins pipeline
pipeline {
agent {
docker {
// Use a Docker image that has Maven, Java 21, and (optionally) Docker CLI installed.
image 'jelastic/maven:3.9.5-openjdk-21'
// Mount the host Docker socket so the container can run docker commands.
args '--user root -v /var/run/docker.sock:/var/run/docker.sock'
}
}
environment {
// Define your Docker image name (update with your Docker Hub username and image name)
DOCKER_IMAGE = "rajputuser/docker-shivam-imz:latest"
// Set the SonarQube URL. Update this IP if needed.
SONAR_URL = "http://172.17.0.2:9000"
}
stages {
stage('Build and Test') {
steps {
// List files (for debugging) and run Maven to clean, compile, test, and package your app.
sh 'ls -ltr'
sh 'mvn clean package'
}
}
stage('SonarQube Analysis') {
steps {
// Run SonarQube analysis using Maven.
// Credentials for SonarQube are injected via SONAR_TOKEN.
withCredentials([string(credentialsId: 'sonarqube', variable: 'SONAR_TOKEN')]) {
sh 'mvn sonar:sonar -Dsonar.login=$SONAR_TOKEN -Dsonar.host.url=${SONAR_URL}'
echo 'SonarQube analysis completed successfully!'
}
}
}
stage('Build Docker Image') {
agent {
docker {
image 'abhishekf5/maven-abhishek-docker-agent:v1'
args '--user root --privileged -v /var/run/docker.sock:/var/run/docker.sock' // mount Docker socket to access the host's Docker daemon
}
}
steps {
// Build the Docker image using the Dockerfile in the workspace.
sh 'docker build -t $DOCKER_IMAGE .'
}
}
stage('Push Docker Image') {
agent {
docker {
image 'abhishekf5/maven-abhishek-docker-agent:v1'
args '--user root --privileged -v /var/run/docker.sock:/var/run/docker.sock' // mount Docker socket to access the host's Docker daemon
}
}
steps {
// Log in to Docker Hub and push the built image.
withCredentials([usernamePassword(credentialsId: 'dockerhub', usernameVariable: 'DOCKER_USER', passwordVariable: 'DOCKER_PASS')]) {
sh 'echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin'
sh 'docker push $DOCKER_IMAGE'
}
}
}
stage('Deploy to EC2') {
agent {
docker {
image 'abhishekf5/maven-abhishek-docker-agent:v1'
args '--user root --privileged -v /var/run/docker.sock:/var/run/docker.sock' // mount Docker socket to access the host's Docker daemon
}
}
steps {
// Deploy to an EC2 instance via SSH.
withCredentials([sshUserPrivateKey(credentialsId: '27727626-31a0-4d61-ab9d-18353c0d6b89', keyFileVariable: 'EC2_KEY', usernameVariable: 'EC2_USER')]) {
sh '''
ssh -o StrictHostKeyChecking=no -i $EC2_KEY [email protected] <<EOF
docker pull $DOCKER_IMAGE
docker stop springboot-app || true
docker rm springboot-app || true
docker run -d --name springboot-app -p 8081:8081 $DOCKER_IMAGE
EOF
'''
}
}
}
}
post {
always {
cleanWs() // Clean the workspace after the pipeline completes.
}
}
}
Verified that Jenkins has permission to access /var/run/docker.sock. Checked that the Docker image jelastic/maven:3.9.5-openjdk-21 is pulled correctly. Ensured Jenkins has sufficient resources (CPU, RAM, disk space). Tried adding -D.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true, but no additional logs appeared. Checked if running mvn clean package manually inside the same container works (it does). Restarted Jenkins and Docker service, but the issue persists.
Share Improve this question asked 2 days ago Shivam KumarShivam Kumar 113 bronze badges 1- Here is the repo link github/kumarShivamCodes/pipeline-repo-springboot – Shivam Kumar Commented 2 days ago
1 Answer
Reset to default 0Check for Missing Dependencies
The container may lack required tools (bash
, coreutils
, procps
):
docker run --rm -it jelastic/maven:3.9.5-openjdk-21 sh
apk add --no-cache bash coreutils procps