Reputation: 8835
I'm using the jenkins/jenkins:lts
image at the moment. It runs fine and does everything I want to expect one thing. I want it to run Maven goals in the build steps. The problem is that there is not maven installed in the jenkins container environment.
So I want to extend the mentioned image to run an apt-get install maven
.
My solution:
FROM "jenkins/jenkins:lts
USER root
RUN /bin/bash -c "apt-get install maven"
Will this be enough? I assume that all RUN and ENTRYPOINT steps of the jenkins image will run by itself and I do not need to re-execute them in my Dockerfile right?
Upvotes: 12
Views: 21620
Reputation: 111
Works file for me
FROM jenkins/jenkins:lts
USER root
RUN apt-get update && apt-get install -y maven
Upvotes: 2
Reputation: 2983
According to the documentation, this would be in your dockerfile
FROM jenkins/jenkins:lts
# if we want to install via apt
USER root
RUN apt-get update && apt-get install -y maven
# drop back to the regular jenkins user - good practice
USER jenkins
Assuming your docker file is in your current directory this is how you would build the image and install in your local docker repo
docker build -t jenkins-maven .
For more information
https://github.com/jenkinsci/docker
After installing maven this way, the mvn version will probably be older than what you need. When I ran this, it was Apache Maven 3.3.9
Upvotes: 12
Reputation: 97
Here is the simplest way to install maven into docker:
Connect to docker with root privilages
sudo docker exec -u root -t -i [container-id] bash
update and install maven
apt-get update & apt-get install
That's it.
Upvotes: 5
Reputation: 10185
you need to update package cache before install, and don't miss -y
for apt-get install
.
FROM jenkins/jenkins:lts
RUN apt-get update && apt-get install -y maven
Upvotes: 11