FROM ubuntu:jammy-20260210.1 AS builder
# Install build tools (OpenJDK 8, Maven) and git
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends openjdk-8-jdk maven ca-certificates git \
&& rm -rf /var/lib/apt/lists/*
# Prepare build workspace
WORKDIR /workspace
# Copy pom and sources
COPY pom.xml .
COPY src ./src
# Ensure JAVA_HOME for Maven
ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
ENV PATH="$JAVA_HOME/bin:$PATH"
# Build the project from source
RUN mvn -Ddoclint=all --show-version --batch-mode --no-transfer-progress
# Final runtime stage (smaller image but with built artifact)
FROM ubuntu:jammy-20260210.1
ENV DEBIAN_FRONTEND=noninteractive
# Keep the runtime lean: only CA certificates needed to verify HTTPS connections
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Create directory for artifacts
RUN mkdir -p /usr/local/lib/commons-csv
# Copy the built artifact from the builder stage
COPY --from=builder /workspace/target/commons-csv-1.14.2-SNAPSHOT.jar /usr/local/lib/commons-csv/commons-csv-1.14.2-SNAPSHOT.jar
# Expose a simple shell as the default command to interact with the container
CMD ["bash"]
# Exclude VCS and IDE files .git .gitignore **/.git # Exclude build outputs and large caches target **/target # Exclude IDE/editor directories **/.idea **/.vscode # OS files **/.DS_Store # Misc *.log *.tmp *~
Concerns: No Java runtime is installed in the final runtime image, so the built JAR cannot be executed (container runs bash by default instead of a Java runtime)., CMD is set to launch a shell (bash) rather than auto-running the produced JAR or providing a runnable entrypoint with java -jar., Build step uses mvn with no explicit goal; unless the POM defines a defaultGoal, the artifact may not be produced. It would be safer to specify mvn -D... package (or install)., The COPY path assumes the artifact name commons-csv-1.14.2-SNAPSHOT.jar; if the Maven build changes the output name or version, the COPY will fail. Consider parameterizing or using a more flexible approach (e.g., mvn -D... package && cp target/*.jar ...).
FROM ubuntu:jammy-20260210.1 AS builder
# Install build tools (OpenJDK 8, Maven) and git
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends openjdk-8-jdk maven ca-certificates git \
&& rm -rf /var/lib/apt/lists/*
# Prepare build workspace
WORKDIR /workspace
# Copy pom and sources
COPY pom.xml .
COPY src ./src
# Ensure JAVA_HOME for Maven
ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
ENV PATH="$JAVA_HOME/bin:$PATH"
# Build the project from source (skip tests for lighter builds)
RUN mvn -Ddoclint=all --show-version --batch-mode --no-transfer-progress -DskipTests
# Final runtime stage (smaller image but with built artifact)
FROM ubuntu:jammy-20260210.1
ENV DEBIAN_FRONTEND=noninteractive
# Install runtime Java and necessary certificates
RUN apt-get update \
&& apt-get install -y --no-install-recommends openjdk-8-jre ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy the built artifact from the builder stage
COPY --from=builder /workspace/target/commons-csv-1.14.2-SNAPSHOT.jar /app/commons-csv-1.14.2-SNAPSHOT.jar
COPY --from=builder /workspace/target /app/target
# Create an entrypoint script that will run the jar
RUN bash -lc 'cat > /entrypoint.sh <<"EOS" \
#!/bin/sh\nset -e\nJAR=$(ls -1 /app/target/commons-csv-*.jar 2>/dev/null | head -n1)\nif [ -z "$JAR" ]; then\n echo "No jar found in /app/target" >&2\n exit 1\nfi\nexec java -jar "$JAR" "$@"\nEOS' \
&& chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
Build status: VerifyBuild: build_failed Failing step and exit - [builder 2/6] RUN apt-get update && apt-get install -y --no-install-recommends openjdk-8-jdk maven ca-certificates git && rm -rf /var/lib/apt/lists/* - Exit code: 100 - The overall build ends with: "ERROR: ...: exit code: 100" Exact error messages to preserve - update-alternatives: error: error creating symbolic link '/usr/share/binfmts/jar.dpkg-tmp': No such file or directory - dpkg: error processing package openjdk-11-jre-headless:amd64 (--configure): installed openjdk-11-jre-headless:amd64 package post-installation script subprocess returned error exit status 2 - E: Sub-process /usr/bin/dpkg returned an error code (1) - head: cannot open '/etc/ssl/certs/java/cacerts' for reading: No such file or directory Version/mismatch details - The log shows multiple Java versions being configured during the same apt install (openjdk-8-jdk, openjdk-11-jre-headless, openjdk-8-jre-headless, etc.), suggesting a Java version conflict/unexpected upgrade path. - The final failure occurs during configuring openjdk-11-jre-headless:amd64, after which dpkg reports the error. Missing packages/files mentioned - /usr/share/binfmts/jar.dpkg-tmp (causes update-alternatives failure) - /etc/ssl/certs/java/cacerts (head: cannot open ... cacerts) Notes - The error is tied to the apt-get install step pulling and configuring multiple Java components; immediate blocker is the post-install failure of openjdk-11-jre-headless and the missing system paths. Remediation ideas (actionable) - Use a single, supported JDK version (e.g., OpenJDK 11 or 17) and remove conflicting Java components from the build. - Ensure the jar.dpkg-tmp path exists or adjust update-alternatives usage to avoid that failure. - Ensure /etc/ssl/certs/java/cacerts exists (install/repair ca-certificates-java as needed).
# Multi-stage build: build with Maven + OpenJDK 8, then run with a lightweight JRE FROM maven:3.8.7-openjdk-8 AS builder WORKDIR /build # Copy project files and build (skipping tests for a quicker build) COPY pom.xml . COPY src ./src RUN mvn -Ddoclint=all --show-version --batch-mode --no-transfer-progress -DskipTests package # Final runtime image with JRE 8 FROM eclipse-temurin:8-jre WORKDIR /app # Copy built jar from builder stage (artifact name matches pom: commons-csv-1.14.2-SNAPSHOT.jar) COPY --from=builder /build/target/commons-csv-1.14.2-SNAPSHOT.jar /app/commons-csv-1.14.2-SNAPSHOT.jar # Run the built jar by default (if the project exposes a main class in this jar) ENTRYPOINT ["java", "-jar", "/app/commons-csv-1.14.2-SNAPSHOT.jar"]
Image maven:3.8.7-openjdk-8 NOT found on Docker Hub.
openjdk (4111 stars): Pre-release / non-production builds of OpenJDK cimg/openjdk (8 stars): The CircleCI OpenJDK (Java) Docker Convenience Image. circleci/openjdk (12 stars): CircleCI images for OpenJDK maven (1666 stars): Apache Maven is a software project management and comprehension tool. dockereng/network-test-image (2 stars): Image used in E2E test focused on networking validation docker/dockerfile (125 stars): Official Dockerfile frontend images that enable building Dockerfiles with BuildK dockereng/network-test-image-win (2 stars): Used for windows end to end testing docker/ucp-auth (4 stars): Please refer to the docker/ucp image for more information docker/dockerfile-copy (1 stars): (deprecated) docker/docker-model-backend-llamacpp (1 stars):
Image maven:3.8.1-openjdk-8 exists on Docker Hub.
# Multi-stage build: build with Maven + OpenJDK 8, then run with a lightweight JRE FROM maven:3.8.1-openjdk-8 AS builder WORKDIR /build # Copy project files and build (skipping tests for a quicker build) COPY pom.xml . COPY src ./src RUN mvn -Ddoclint=all --show-version --batch-mode --no-transfer-progress -DskipTests package # Final runtime image with JRE 8 FROM openjdk:8-jre-slim WORKDIR /app # Copy built jar from builder stage (artifact name matches pom: commons-csv-1.14.2-SNAPSHOT.jar) COPY --from=builder /build/target/commons-csv-1.14.2-SNAPSHOT.jar /app/commons-csv-1.14.2-SNAPSHOT.jar # Run the built jar by default ENTRYPOINT ["java", "-jar", "/app/commons-csv-1.14.2-SNAPSHOT.jar"]
Image openjdk:8-jre-slim NOT found on Docker Hub.
maven (1666 stars): Apache Maven is a software project management and comprehension tool. kasmweb/core-ubuntu-jammy (13 stars): Ubuntu Jammy base image for Kasm Workspaces kasmweb/ubuntu-jammy-desktop (42 stars): Ubuntu productivity desktop for Kasm Workspaces kasmweb/ubuntu-jammy-dind (7 stars): Docker for Kasm Workspaces kasmweb/ubuntu-jammy-dind-rootless (3 stars): Rootless Docker for Kasm Workspaces kasmweb/ubuntu-jammy-desktop-vpn (0 stars): Ubuntu productivity desktop for Kasm Workspaces with tools for connecting to a V paketobuildpacks/build-jammy-base (0 stars): dockereng/network-test-image (2 stars): Image used in E2E test focused on networking validation paketobuildpacks/build-jammy-full (0 stars): paketobuildpacks/build-jammy-tiny (0 stars):
adoptopenjdk (378 stars): DEPRECATED; use https://hub.docker.com/_/eclipse-temurin/ rapidfort/tomcat-openjdk8-ib (0 stars): RapidFort optimized, hardened image for Tomcat Ironbank dockette/openjdk8 (1 stars): My OpenJDK 8 Dockerfile cbioportal/3dhotspots (0 stars): adoptopenjdk/openjdk8 (150 stars): Docker Images for OpenJDK Version 8 binaries built by AdoptOpenJDK. adoptopenjdk/openjdk8-openj9 (55 stars): Docker Images for Eclipse OpenJ9 Version 8 binaries built by AdoptOpenJDK. cbioportal/cancerhotspots (0 stars): adoptopenjdk/maven-openjdk8 (8 stars): Apache Maven 3.6.1 Docker Images based on OpenJDK 8 builds by AdoptOpenJDK. adoptopenjdk/openjdk11 (227 stars): Docker Images for OpenJDK Version 11 binaries built by AdoptOpenJDK. adoptopenjdk/maven-openjdk8-openj9 (1 stars): Apache Maven 3.6.1 Docker Images based on Eclipse OpenJ9 Version 8 builds by Ado
openjdk (4111 stars): Pre-release / non-production builds of OpenJDK kasmweb/core-ubuntu-jammy (13 stars): Ubuntu Jammy base image for Kasm Workspaces paketobuildpacks/build-jammy-base (0 stars): dockereng/network-test-image (2 stars): Image used in E2E test focused on networking validation kasmweb/ubuntu-jammy-desktop (42 stars): Ubuntu productivity desktop for Kasm Workspaces paketobuildpacks/build-jammy-full (0 stars): kasmweb/ubuntu-jammy-dind (7 stars): Docker for Kasm Workspaces paketobuildpacks/build-jammy-tiny (0 stars): paketobuildpacks/run-jammy-base (0 stars): paketobuildpacks/run-jammy-full (0 stars):
# Multi-stage build: compile with Maven (Java 8) and run with a minimal OpenJDK 8 runtime FROM maven:3.8.1-openjdk-8 AS builder WORKDIR /workspace # Copy project files and build (skipping tests for a quicker build) COPY pom.xml . COPY src ./src RUN mvn -Ddoclint=all --show-version --batch-mode --no-transfer-progress -DskipTests package # Final runtime image with OpenJDK 8 FROM adoptopenjdk/openjdk8 AS runtime WORKDIR /app # Copy built jar from builder stage COPY --from=builder /workspace/target/commons-csv-1.14.2-SNAPSHOT.jar /app/commons-csv-1.14.2-SNAPSHOT.jar # Provide a non-blocking default shell CMD ["/bin/sh"]
Smoke [PASS]: test -f /app/commons-csv-1.14.2-SNAPSHOT.jar Smoke [PASS]: java -version Smoke [PASS]: ls -l /app