Jib — Build Java Container Images Without Docker
Jib is a Google-built tool that containerizes Java applications directly from Maven or Gradle without a Dockerfile or Docker daemon, producing optimized, layered OCI images.
Installation agent prête
Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.
npx -y tokrepo@latest install 0251f5a0-3987-11f1-9bc6-00163e2b0d79 --target codexÀ exécuter après confirmation du plan en dry-run.
What it is
Jib is a container image builder created by Google that packages Java applications into optimized, layered OCI images directly from your Maven or Gradle build. No Dockerfile required. No Docker daemon required. Jib understands Java application structure and creates efficient image layers that separate dependencies from application code.
This tool is for Java developers and platform teams who want to containerize applications without learning Docker internals. It integrates into existing build tools so containerization is just another build step.
How it saves time or tokens
Jib eliminates the Dockerfile-write-build-push workflow. You add a plugin to your pom.xml or build.gradle, and mvn jib:build or gradle jib pushes a production-ready image. Layer optimization means only changed layers are rebuilt and pushed, saving CI time. The build is reproducible: same source always produces the same image.
How to use
- Add the Jib plugin to your Maven or Gradle build file.
- Configure the target image registry.
- Run the build command.
- The image is pushed directly to the registry.
<!-- Maven pom.xml -->
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.4.0</version>
<configuration>
<to>
<image>gcr.io/myproject/myapp</image>
</to>
</configuration>
</plugin>
# Build and push image (no Docker needed)
mvn compile jib:build
# Build to local Docker daemon
mvn compile jib:dockerBuild
# Build to a tar file
mvn compile jib:buildTar
Example
Gradle configuration:
plugins {
id 'com.google.cloud.tools.jib' version '3.4.0'
}
jib {
from {
image = 'eclipse-temurin:21-jre'
}
to {
image = 'gcr.io/myproject/myapp'
tags = ['latest', project.version]
}
container {
mainClass = 'com.myapp.Main'
ports = ['8080']
jvmFlags = ['-Xms256m', '-Xmx512m']
}
}
Run gradle jib and the image is built and pushed.
Related on TokRepo
- DevOps tools — Container and deployment tools
- Automation tools — Build automation for CI/CD
Common pitfalls
- Jib pushes directly to a registry by default. Ensure your registry credentials are configured in Maven settings or Gradle properties.
- The base image must be compatible with your JDK version. Mismatched JDK versions cause runtime errors.
- Native dependencies or custom filesystem modifications need extra configuration since there is no Dockerfile to customize.
- Jib optimizes for standard Java applications. If your app has non-Java components (native binaries, config files in unusual locations), you need Jib's extra directories feature.
- Build reproducibility requires pinning the base image tag. Using
latestcreates non-reproducible builds. - Review the official documentation before deploying to production to ensure compatibility with your specific environment and requirements.
Questions fréquentes
No. Jib builds container images without a Docker daemon. It constructs image layers directly and pushes them to a registry. You can optionally use jib:dockerBuild to build to a local Docker daemon if you have one.
Jib supports any OCI-compliant registry: Docker Hub, Google Container Registry, AWS ECR, Azure Container Registry, GitHub Container Registry, and private registries. Authentication is configured through Maven settings or Gradle properties.
Jib separates your application into multiple layers: dependencies, resources, and classes. Since dependencies change less frequently than application code, most builds only rebuild and push the classes layer, saving time and bandwidth.
Yes. Set the from.image configuration to any base image. Common choices include eclipse-temurin, amazoncorretto, or custom base images. Jib defaults to a distroless Java base image for minimal attack surface.
Yes. Jib automatically detects Spring Boot applications and configures the main class and classpath correctly. No special configuration is needed for standard Spring Boot projects.
Sources citées (3)
- Jib GitHub— Jib builds Java container images without Docker
- Jib Maven Plugin Docs— Jib Maven plugin configuration
- OCI Image Spec— OCI image specification for container images
En lien sur TokRepo
Fil de discussion
Actifs similaires
Apache Tomcat — The Java Servlet Container That Powers the Web
Apache Tomcat is an open-source implementation of the Jakarta Servlet, JSP, and WebSocket specifications, serving as the default deployment target for millions of Java web applications worldwide.
Quarkus — Supersonic Subatomic Java Framework
A Kubernetes-native Java framework by Red Hat tailored for GraalVM native images and HotSpot, delivering fast startup and low memory usage for microservices.
Earthly — Build Automation for the Container Era
Earthly combines the best of Dockerfiles and Makefiles into a single repeatable build tool. Define builds in an Earthfile, and Earthly caches, parallelizes, and runs them identically on laptop or CI.
cAdvisor — Real-Time Container Resource Monitoring by Google
Analyze container resource usage and performance with Google's cAdvisor. Native Docker support, Prometheus metrics export, and zero-config deployment for production container monitoring.