Introduction
Jib is an open-source container image builder from Google that packages Java applications into optimized Docker and OCI images without requiring a Dockerfile, a Docker daemon, or even Docker installed on the machine. It integrates directly into Maven and Gradle as a plugin, making containerization a natural part of the Java build lifecycle. Jib understands Java application structure and creates fine-grained layers that maximize cache reuse.
What Jib Does
- Builds container images for Java apps directly from Maven or Gradle without Docker
- Creates optimized, reproducible image layers separating dependencies, resources, and classes
- Pushes images directly to any OCI-compatible registry without a local daemon
- Supports both distroless and custom base images for minimal attack surface
- Provides a Java library (Jib Core) for programmatic image building
Architecture Overview
Jib hooks into the Java build tool lifecycle and reads your project's compiled output. It separates the application into distinct layers: dependencies, snapshot dependencies, resources, and class files. Each layer is hashed and only rebuilt when its content changes. Jib then assembles an OCI image manifest and pushes layers directly to the registry using the registry HTTP API, bypassing the Docker daemon entirely. This makes builds faster, more reproducible, and CI-friendly.
Self-Hosting & Configuration
- Add the jib-maven-plugin or jib-gradle-plugin to your build file with the target image name
- Configure the base image with jib.from.image (defaults to Eclipse Temurin distroless)
- Set JVM flags, environment variables, and ports in the jib.container configuration block
- Use jib.to.auth or credential helpers for registry authentication (GCR, ECR, Docker Hub)
- Run jib:build for direct registry push or jib:dockerBuild to load into local Docker
Key Features
- No Dockerfile and no Docker daemon required — builds run entirely in the JVM process
- Smart layering separates rarely-changing dependencies from frequently-changing code for fast rebuilds
- Reproducible builds produce byte-identical images across different machines and CI runs
- Native credential helper integration for GCR, ECR, ACR, and Docker Hub
- Jib Core library enables custom image building from any Java application or framework
Comparison with Similar Tools
- Dockerfile + docker build — flexible but requires Docker daemon, manual layer optimization, and is not reproducible by default
- Buildpacks (Paketo) — auto-detect and build but slower, opaque layering, and less control over image contents
- ko — similar daemonless approach but only for Go applications, not Java
- Kaniko — builds Dockerfiles inside containers for CI but still requires a Dockerfile and is slower than Jib
- Spring Boot Buildpacks — convenient for Spring apps but uses Paketo under the hood with less customization
FAQ
Q: Does Jib work with Spring Boot, Quarkus, and other frameworks? A: Yes. Jib works with any Java application that produces a JAR or WAR. It has been tested extensively with Spring Boot, Quarkus, Micronaut, and plain Java.
Q: How much faster is Jib compared to docker build? A: Incremental builds are typically 5-10x faster because Jib only rebuilds and pushes the layers that changed, and it does not need to start a Docker daemon.
Q: Can I use a custom base image? A: Yes. Set jib.from.image to any image, such as eclipse-temurin:21-jre-alpine or your own corporate base image.
Q: Does Jib support multi-platform images? A: Jib supports building for specific platforms via the platforms configuration. Multi-arch manifest lists require building each platform separately and merging.