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,700 points
5,641 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
• 10,620 points
Thanks a mil. This really helped me.

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
• 7,060 points
3,533 views
+2 votes
1 answer

Not able to create docker robot framework image

Did your try FROM Python3 READ MORE

answered Aug 21, 2020 in Docker by anonymous
2,201 views
+2 votes
1 answer
+2 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
• 58,020 points
2,739 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP