Table of Contents
What is Google Jib?
Google Jib is a Plugin developed by Google engineers to build and containerize Java Applications without a docker file.
Jib Plugin is available with Maven and Gradle, or you can also use it as a library.

Maven / Gradle Plugin
To use the Google Jib plugin you need to add it to your project dependency as a plugin.
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<to>
<image>gcr.io/PROJECT/IMAGE</image>
</to>
</configuration>
</plugin>
In the above dependency, we are using the Google repository as a container registry. If you are using any other public or private container registry you need to replace the details.
Replace :
Project with you Project Details
Image with you Image Name
Building and Publishing the Image
mvn compile jib:build
The above command will run a pre-defined jib task to build and publish images to the repository.
Customizations
Similar to Dockerfile you can add environment variables to the Jib build & update the base image used.
Adding Environment Variables
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>2.8.0</version>
<configuration>
<to>
<image>gcr.io/PROJECT/IMAGE</image>
</to>
<container>
<environment>
<ENV_VAR>VALUE</ENV_VAR>
</environment>
</container>
</configuration>
</plugin>
In the above configuration replace the details.
Replace:
Project with you Project Details
Image with you Image Name
ENV_VAR with the Name of the variable
Value with the desired value
Changing the Base Image
For creating a container image base image is used as the base layer and then other layers are added to generate the final image.
As per our requirements, we can update the base image as needed. For example, if a Java base image is needed we can update to “alpine:3” or “openjdlk: VERSION“
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>2.8.0</version>
<configuration>
<from>
<image>gcr.io/PROJECT/BASE_IMAGE</image>
</from>
<to>
<image>gcr.io/PROJECT/IMAGE_NAME</image>
</to>
</configuration>
</plugin>
Leave a Reply