It is simple, really

Meet Jib: Containerizing a Java application has never been easier

© Shutterstock / Oktyabr  

“Write once, run anywhere” has been the Java motto since forever! And what better way to achieve that if not with the use of containers? But we all know that containerizing Java applications is anything but simple. Jib is an open-source Java containerizer from Google that aspires to make a difference!

“Write once, run anywhere” (WORA), or sometimes “write once, run everywhere” (WORE), has been the motto that describes the cross-platform benefits of the Java language for ages and containers are bringing Java developers closer than ever to the realization of this type of workflow.

Don’t get me wrong though. Containerizing a Java application is no easy business and that was the main driver behind the creation of Jib.

Jib, an open-source Java containerizer created by Google lets Java developers build containers using the Java tools they are familiar with. It builds Docker and OCI images for your Java applications and is available as plugin for Maven and Gradle.

Jib was created in order to handle all the steps of packaging your application into a container image and it does not require you to write a Dockerfile or have docker installed since it is directly integrated into Maven and Gradle.

Let’s take a look at the visual representation of the build flow in comparison to Docker:

Docker build flow:


Jib build flow:

The goals behind Jib’s creation are threefold:

  • Be fast – Deploy your changes fast. Jib separates your application into multiple layers, splitting dependencies from classes. Now you don’t have to wait for Docker to rebuild your entire Java application – just deploy the layers that changed.
  • Be reproducible – Rebuilding your container image with the same contents always generates the same image. Never trigger an unnecessary update again.
  • Be daemonless – Reduce your CLI dependencies. Build your Docker image from within Maven or Gradle and push to any registry of your choice. No more writing Dockerfiles and calling docker build/push.

And how does it work, you ask?

According to its GitHub repo, whereas a Java application is traditionally built as a single image layer with the application JAR, “Jib’s build strategy separates the Java application into multiple layers for more granular incremental builds. When you change your code, only your changes are rebuilt, not your entire application. These layers, by default, are layered on top of a distroless base image.”

SEE ALSO: Nobody puts Java in a container

If you have more questions or comments like “But, I’m not a Java developer” or “I just want to set some JVM flags when running the image”, make sure to take a look at the FAQ section. 

Getting started

You can add Jib as a plugin for Maven and Gradle and it requires minimal configuration. Simply add the plugin to your build definition and configure the target image.

Jib on Maven

# Builds to a container image registry.
$ mvn compile jib:build
# Builds to a Docker daemon.
$ mvn compile jib:dockerBuild

See the documentation for jib-maven-plugin.

Jib on Gradle

plugins {
  id '' version '0.9.0'
} = ''
# Builds to a container image registry.
$ gradle jib
# Builds to a Docker daemon.
$ gradle jibDockerBuild

See the documentation for jib-gradle-plugin.

You have to keep in mind, however, that if you are building to a private registry, you should make sure to configure Jib with credentials for your registry.


Eirini-Eleni Papadopoulou
Eirini-Eleni Papadopoulou was the editor for Coming from an academic background in East Asian Studies, she decided that it was time to go back to her high-school hobby that was computer science and she dived into the development world. Other hobbies include esports and League of Legends, although she never managed to escape elo hell (yet), and she is a guest writer/analyst for competitive LoL at TGH.

Inline Feedbacks
View all comments
Gabriela Motroc
Gabriela Motroc
Reply to  Test
3 years ago

The link has already been included in the article above but thank you for making it more obvious