maven
Maven Overview
Secure your stack with a hardened Maven image freshly-built by Minimus. Minimus images always include the most up-to-date package version for all packages and dependencies contained in the image.
Use this image to set up a build automation and project management tool. Apache Maven is primarily used for Java projects to manage dependencies, compile code, run tests, and package applications.
Try It Out
To take the Minimus Maven image for a test run we will create a simple Java application. The multi-stage Dockerfile builds the app with Maven and uses OpenJRE as the runtime.
First, save the following code to your Dockerfile:
# === Build Stage ===
FROM reg.mini.dev/maven AS builder
USER root
# Create the /app directory and set permissions
RUN mkdir -p /app && chown -R 1000:1000 /app
# Switch to user 1000 explicitly (if not already)
USER 1000
# Set working directory
WORKDIR /app
# Copy Maven configuration files
COPY --chown=1000:1000 pom.xml .
# Copy source code
COPY --chown=1000:1000 src ./src
# Build the application
RUN mvn clean package -DskipTests
# === Runtime Stage ===
FROM reg.mini.dev/openjre AS runtime
# Set working directory
WORKDIR /app
# Copy the JAR file from builder stage
COPY --from=builder /app/target/simple-java-app-1.0.0.jar app.jar
# Set environment variables
ENV APP_ENV=production
ENV JAVA_OPTS="-Xms128m -Xmx256m"
# Expose the web port
EXPOSE 8080
# Run the application
ENTRYPOINT ["java", "-Xms128m", "-Xmx256m", "-jar", "app.jar"]Note that the /app directory is created with root ownership by default so we set permissions for user 1000:1000.
Next, download the sample pom.xml file (link). The Project Object Model file instructs Maven how to build the project and is required to build the app.
Place the sample Java app and HTML page under dedicated paths:
-
Download the Java sample app
App.java(link) and save it under the pathsrc/main/java/com/example/app:
mkdir -p src/main/java/com/example/app mv App.java src/main/java/com/example/app/ -
Download the sample HTML page
home.html(link) and save it under the pathsrc/main/resources/templates/:
mkdir -p src/main/resources/templates/ mv home.html src/main/resources/templates/
Your project directory should now look like this:
├── Dockerfile
├── pom.xml
└── src
└── main
├── java
│ └── com
│ └── example
│ └── app
│ └── App.java
└── resources
└── templates
└── home.htmlNext, build and run your sample app. Note that the period . specifies the current directory as the build context:
docker build -t minimus-java-app .
docker run --rm -p 8080:8080 minimus-java-appVisit the landing page at http://localhost:8080. You should see the title Demo Java Application for Minimus and a timestamp of when the application started.
Technical Considerations
The Maven image provided by Minimus is a slim, security-hardened alternative to the public image from Docker Hub. The images are largely interchangeable, with a few differences as noted below.
Maven built by Minimus:
- Minimus Maven image lines are organized by their Maven version and OpenJDK versions. Use the version tag that matches your application build requirements, for example:
3.9-jdk24. - Runs as non-root by default for a security-first approach that protects against privilege escalation attacks. The public image runs as root.
- The default working directory is
/home/build. The public image working directory defaults to the root directory. - The entrypoint is
/usr/bin/mvn. The public image entrypoint script is/usr/local/bin/mvn-entrypoint.shwith the default command ["mvn"]. - Drill down on the version specification tab to see the default user, listening ports, entrypoint, volumes, environment variables, etc.
The Payoff
A hardened, minimal image that will remain more secure for the long run and accrue vulnerabilities at a slower rate.
- See the risk reduction dashboard for a detailed CVE comparison over the past 30 days.
- Review the compliance report to see the default hardening and security configurations for the image.
Terms & Info
Trademark
This catalog is published by Minimus. All product names, logos, and marks, other than those belonging to Minimus, shown are owned by their respective rights holders and appear here only to identify the open source software each image contains. Minimus claims no ownership of those marks and implies no affiliation with, endorsement by, certification by, or sponsorship by any rights holder.
Disclaimer
Images are provided "as-is" without warranty of any kind. "Hardened" refers to the security configuration applied at the time of build and does not constitute a guarantee of ongoing security or absence of vulnerabilities. The free tier is provided without support, SLA, or guaranteed patching timelines. Security updates may be applied to paid subscriptions before or instead of free tier images. By pulling or using any image you agree to our Terms of Use.