Jib is a maven plugin for building Docker images for your java applications.
In this post, I’m going to demonstrate how you can use it in order to create the Docker image for a simple java application.
First we need to create a simple java application using the maven quickstart archetype :
mvn archetype:generate -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeVersion=1.4 -DgroupId=com.sergouniotis -DartifactId=java-application -Dversion=1.0.0 -Dpackage=com.sergouniotis
Then we can containerize our application easily with the command below :
mvn compile com.google.cloud.tools:jib-maven-plugin:3.1.4:build -Dimage=tsergouniotis/sample-application
This builds and pushes a container image for your application to a container registry
[INFO] --- jib-maven-plugin:3.1.4:build (default-cli) @ sample-application --- [INFO] [INFO] Containerizing application to tsergouniotis/sample-application... [WARNING] Base image 'adoptopenjdk:8-jre' does not use a specific image digest - build may not be reproducible [INFO] Using credentials from Docker config (/home/sergouniotis/.docker/config.json) for tsergouniotis/sample-application [INFO] The base image requires auth. Trying again for adoptopenjdk:8-jre... [INFO] Using credentials from Docker config (/home/sergouniotis/.docker/config.json) for adoptopenjdk:8-jre [INFO] Using base image with digest: sha256:47dd9f792d311bb7e702c415283a924aebff5dea640f936ece4fdf8dba135b73 [INFO] [INFO] Container entrypoint set to [java, -cp, /app/resources:/app/classes:/app/libs/*, com.sergouniotis.App] [INFO] [INFO] Built and pushed image as tsergouniotis/sample-application [INFO] Executing tasks: [INFO] [============================ ] 91.7% complete [INFO] > launching layer pushers
The image was pushed into docker registry

Now by running the docker container we can see the ‘Hello World’ message printing
$ docker run --rm tsergouniotis/sample-application --name sample-application Hello World!
You can find further details and documentation in the following link
https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin