Recommended Docker Images for Backend Services
This document outlines the recommended Docker images for building and running backend services in the data-viz project. Individual projects and services need to be updated separately to use these recommended images.
Overview​
The data-viz project recommends using Eclipse Temurin-based Docker images for Java development and runtime. Eclipse Temurin is the open-source distribution of the OpenJDK, maintained by the Eclipse Adoptium project, providing reliable and well-maintained Java runtime environments.
Recommended Images​
Maven Build Image​
Image: maven:3-eclipse-temurin-21
Use this image for building Java applications with Maven.
FROM maven:3-eclipse-temurin-21 AS compiler
WORKDIR /opt/viz
# ... your build steps
Why this image?
- Combines Maven 3 with Eclipse Temurin JDK 21
- Provides a consistent build environment
- Well-maintained and regularly updated
- Suitable for CI/CD pipelines
JRE Runtime Image (Recommended for Production)​
Image: eclipse-temurin:21-jre-alpine
Use this image for running Java applications in production environments.
FROM eclipse-temurin:21-jre-alpine
WORKDIR /opt/viz
COPY /opt/viz ./
# ... your runtime configuration
Why this image?
- Alpine-based: Smaller image size, reducing deployment footprint and improving security
- JRE only: Contains only the Java Runtime Environment, not the full JDK
- Production-optimized: Minimal image size while maintaining full runtime capabilities
- Security: Alpine Linux provides a smaller attack surface
- Performance: Smaller images mean faster pulls and deployments
When to use: Production deployments where you only need to run compiled Java applications.
JDK Runtime Image​
Image: eclipse-temurin:21-jdk-alpine
Use this image when you need development tools or compilation capabilities at runtime.
FROM eclipse-temurin:21-jdk-alpine
WORKDIR /opt/viz
# ... your configuration
Why this image?
- Full JDK: Includes development tools, compilers, and debugging utilities
- Alpine-based: Smaller than standard JDK images
- Development-friendly: Useful for development environments or when runtime compilation is needed
When to use:
- Development environments
- Applications that require runtime compilation
- Debugging scenarios where development tools are needed
Note: The JDK image is larger than the JRE image. Use JRE for production unless you specifically need JDK features.
Alternative Eclipse Temurin Images​
You can use other Eclipse Temurin images, but they will be larger:
Standard Images (Larger)​
eclipse-temurin:21-jre- Standard JRE (larger than Alpine)eclipse-temurin:21-jdk- Standard JDK (larger than Alpine)eclipse-temurin:21-jre-jammy- Ubuntu-based JREeclipse-temurin:21-jdk-jammy- Ubuntu-based JDK
When to consider alternatives:
- If you need specific system libraries not available in Alpine
- If you encounter compatibility issues with Alpine's musl libc
- If your application requires glibc-based distributions
Trade-offs:
- Larger image sizes (typically 1.5-3x larger than Alpine)
- More system packages and dependencies
- Potentially longer build and pull times
Migration Guide​
Updating Build Images​
If your project currently uses Amazon Corretto or other Maven images:
Before:
FROM maven:3-amazoncorretto-21 AS compiler
After:
FROM maven:3-eclipse-temurin-21 AS compiler
Updating Runtime Images​
If your project currently uses OpenJDK or other runtime images:
OpenJDK Images Deprecation Notice
- OpenJDK images were deleted from the Docker Registry.
- You should use the Eclipse Temurin images instead.
- See the deprecation notice here
Before:
# OpenJDK images were deleted.
FROM openjdk:21-jdk-slim
After (Production - Recommended):
FROM eclipse-temurin:21-jre-alpine
After (Development/Debugging):
FROM eclipse-temurin:21-jdk-alpine
Example Multi-stage Dockerfile​
Here's a complete example using the recommended images:
# Build stage
FROM maven:3-eclipse-temurin-21 AS compiler
WORKDIR /opt/viz
COPY ./pom.xml ./pom.xml
RUN \
mvn -B dependency:go-offline
COPY ./src ./src
RUN \
mvn -B package -DskipTests
# Runtime stage (Production)
FROM eclipse-temurin:21-jre-alpine
WORKDIR /opt/viz
# Install curl for health checks (if needed)
RUN apk add --no-cache curl
COPY /opt/viz/target/*.jar app.jar
COPY ./entrypoint.sh ./entrypoint.sh
RUN chmod +x ./entrypoint.sh
EXPOSE 8080
ENTRYPOINT ["./entrypoint.sh"]
Image Size Comparison​
Approximate image sizes (may vary by version):
| Image | Size |
|---|---|
eclipse-temurin:21-jre-alpine | ~65-70 MB |
eclipse-temurin:21-jdk-alpine | ~170-175 MB |
eclipse-temurin:21-jre | ~90-100 MB |
eclipse-temurin:21-jdk | ~200-250 MB |
maven:3-eclipse-temurin-21 | ~225-240 MB |
maven:3-eclipse-temurin-21-alpine | ~180-190 MB |
Note: Alpine-based images are significantly smaller, making them ideal for production deployments.
- Alpine images do come pre-installed with bash, curl, and other useful tools.
- Alpine images are not compatible with glibc.
- You can add other tools to the image by adding them to the Dockerfile.
- Alpine images use busybox as the default shell, which is a minimal shell that is very fast and small. Therefore, if you need to use a different shell (e.g., bash), you can add it to the Dockerfile.
Best Practices​
- Use Alpine for production: Prefer
-alpinevariants for smaller images and faster deployments - Use JRE when possible: Only use JDK if you need compilation or development tools at runtime
- Multi-stage builds: Use separate build and runtime stages to keep final images small
- Cache Maven dependencies: Use Docker build cache mounts for Maven dependencies to speed up builds
- Pin versions: Consider pinning to specific versions for reproducibility (e.g.,
eclipse-temurin:21.0.1-jre-alpine) - Health checks: Add health check endpoints and use
curlorwgetin Alpine images for health checks
Updating Individual Services​
Each service in the data-viz project should be updated separately:
- Update the service's Dockerfile to use the recommended images
- Test the build to ensure compatibility
- Update CI/CD pipelines (e.g., Jenkinsfile) if they reference specific images
- Verify runtime behavior in both development and production environments
Related Documentation​
- Backend Getting Started - Backend development setup
- Backend Deployment - Deployment guide for backend services
- Eclipse Temurin Documentation - Official Eclipse Temurin documentation
- Eclipse Temurin Docker Images - Eclipse Temurin Docker Images