extend jenkins image to install maven extend jenkins image to install maven docker docker

extend jenkins image to install maven


you need to update package cache before install, and don't miss -y for apt-get install.

FROM jenkins/jenkins:ltsRUN apt-get update && apt-get install -y maven


According to the documentation, this would be in your dockerfile

FROM jenkins/jenkins:lts# if we want to install via aptUSER rootRUN apt-get update && apt-get install -y maven# drop back to the regular jenkins user - good practiceUSER 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


Here is the simplest way to install maven into docker:

  1. Connect to docker with root privilages

    sudo docker exec -u root -t -i [container-id] bash

  2. update and install maven

    apt-get update & apt-get install

That's it.