Docker image of maven returns this error - could not create local repository

0 votes

I’m a new bee to Jenkins and Docker, and I’m facing a problem trying to get a docker image of maven to build my project.

My Jenkins script is as follows:

pipeline {
agent {
docker {
image 'maven:3-alpine'
args '-v /root/.m2:/root/.m2'
}
}
stages {
stage('Build') {
steps {
sh 'mvn -B -DskipTests clean install'
}
}
}
}

This results in the following error:

"Could not create local repository at /var/empty/.m2/repository".
Aug 10, 2018 in Docker by Tyrion anex
• 8,270 points
150 views

1 answer to this question.

0 votes

Instead of mounting the root/.m2 folder to the container, you can just run as a root user:

agent {
    docker {
        image 'maven:3-alpine'
        args '-u root'
    } }
answered Aug 10, 2018 by Sophie may
• 9,850 points

Related Questions In Docker

0 votes
1 answer

Init could not choose ip address error while doing docker swarm init

First look for the public IP of ...READ MORE

answered Aug 23, 2018 in Docker by Nilesh
• 6,880 points
308 views
0 votes
1 answer

Slave image does not support running docker

You need to install docker client and ...READ MORE

answered Jul 19, 2018 in Docker by Kalgi
• 2,620 points
525 views
0 votes
1 answer
0 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 56,900 points
189 views
0 votes
1 answer