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,690 points
7,384 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
4,646 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
3,157 views
+2 votes
1 answer
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
7,722 views
0 votes
1 answer

How do I fix this error? docker run --- name “xyz” is already in use by container

You need to remove container "registry-v1". Run docker rm ...READ MORE

answered Feb 19, 2021 in Docker by Abhinav Kumar

edited Mar 5, 2025 13,847 views
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