This image provides a ready-to-use environment for Apache Maven, a powerful project management tool used primarily for Java projects. Maven can manage a project's build, reporting and documentation from a central piece of information.
Built upon a secure and lightweight sourcemation debian slim base image, this Maven container allows you to easily build, test, and package your Java projects without the need for local Maven installation.
To quickly start a shell inside a container with Maven available in the PATH:
docker run -it --rm sourcemation/maven:latest /bin/bash
You can replace latest with a specific version tag.
To build a Maven project located on your host machine, you can mount your project directory into the container:
docker run -it --rm -v /path/to/project:/usr/src/project -w /usr/src/project sourcemation/maven:latest mvn clean install
In this command:
-v /path/to/project:/usr/src/project mounts your local project directory to /usr/src/project inside the container.-w /usr/src/project sets the working directory inside the container to the mounted project directory.mvn clean install executes the Maven build lifecycle goals.You can execute any Maven command by appending it to the docker run command:
docker run -it --rm -v /path/to/project:/usr/src/project -w /usr/src/project sourcemation/maven:latest mvn dependency:tree
This example shows how to generate the dependency tree of your project.
settings.xmlIf you need to use a custom Maven settings.xml file (e.g., for configuring a
private repository), you can mount it into the container:
docker run -it --rm -v /path/to/your/settings.xml:/root/.m2/settings.xml -v /path/to/project:/usr/src/project -w /usr/src/project sourcemation/maven:latest mvn clean install
This mounts your local settings.xml to the default Maven configuration
directory inside the container, mounting your project directory as well and
running the mvn clean install command.
You can also use the Maven archetype plugin to generate a new project structure:
docker run -it --rm -v /path/to/output:/usr/src/out -w /usr/src/out your-maven-image-name mvn archetype:generate -DgroupId=com.example -DartifactId=my-new-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
This command will generate a basic Maven project in the /path/to/output directory on your host.
While this image aims to be straightforward, you might find these environment variables relevant:
MAVEN_CONFIG: Specifies the location of the Maven configuration directory (defaults to /root/.m2).MAVEN_HOME: Points to the Maven installation directory (defaults to /usr/share/maven).MAVEN_VERSION: The version of Maven installed in the image (e.g., 3.9.9)./root/.m2/repository) to speed up
dependency resolution.Contributions are welcome! Propose new features by creating issues or submit pull requests on the Sourcemation GitHub repository.
For more details on Apache Maven, please refer to the official Maven documentation: https://maven.apache.org/.
Sourcemation offers a range of open-source projects and Docker images with extensive risk assessment of open-source software. We are committed to providing high-quality images. Comprehensive risk analysis reports for selected images are available on the Sourcemation platform.
The Maven is licensed under the Apache License 2.0
Content type
Image
Digest
sha256:e775e9634…
Size
290 MB
Last updated
2 days ago
docker pull sourcemation/maven