Esta página se muestra en inglés. Una traducción al español está en curso.
SkillsApr 16, 2026·3 min de lectura

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.

Listo para agents

Instalación lista para agent

Este activo puede instalarse después de elegir el runtime, revisar el plan y ejecutar el comando correspondiente.

Native · 98/100Política: permitir
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
Jib Java Container Builder
Comando de instalación directa
npx -y tokrepo@latest install 0251f5a0-3987-11f1-9bc6-00163e2b0d79 --target codex

Ejecutar después de confirmar el plan con dry-run.

TL;DR
Jib builds optimized Java container images from Maven or Gradle without Docker or a Dockerfile.
§01

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.

§02

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.

§03

How to use

  1. Add the Jib plugin to your Maven or Gradle build file.
  2. Configure the target image registry.
  3. Run the build command.
  4. 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
§04

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.

§05

Related on TokRepo

§06

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 latest creates non-reproducible builds.
  • Review the official documentation before deploying to production to ensure compatibility with your specific environment and requirements.

Preguntas frecuentes

Does Jib require Docker to be installed?+

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.

What registries does Jib support?+

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.

How does Jib optimize image layers?+

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.

Can I customize the base image?+

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.

Does Jib work with Spring Boot?+

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.

Referencias (3)

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados