How to Create a Java Application Docker Image Using Jib Without a Dockerfile
Containerising Java applications is a common requirement in modern development and DevOps workflows.
Most developers use Dockerfiles to create container images. However, maintaining Dockerfiles for every Java application can become repetitive and error-prone.
This is where Jib becomes very useful.
Jib is an open-source tool from Google that allows developers to build optimized Docker and OCI images for Java applications without writing Dockerfiles.
In this article, I will show how to create a Java application image using Jib step by step.
What is Jib?
Jib is a container image build tool for Java applications.
It integrates directly with:
- Maven
- Gradle
Jib simplifies containerisation by:
- removing the need for Dockerfiles
- optimising image layers
- improving build speed
- integrating easily into CI/CD pipelines
Official GitHub:
https://github.com/GoogleContainerTools/jib
Prerequisites
Before starting, ensure the following tools are installed:
- Java 17 or later
- Maven or Gradle
- Docker Desktop (optional for local testing)
Step 1 — Create a Simple Spring Boot Application
You can use any Java application.
For this example, I am using a simple Spring Boot application.
Get Hari Prasad Nattuva’s stories in your inbox
Join Medium for free to get updates from this writer.
Project structure:
demo-app
├── src
├── pom.xml
└── mvnwStep 2 — Add Jib Maven Plugin
Add the following plugin inside the build section of pom.xml.
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.4.3</version> <configuration>
<to>
<image>demo-app:jib</image>
</to>
</configuration>
</plugin>Step 3 — Build Docker Image Using Jib
Run the following Maven command:
mvn compile jib:dockerBuildThis command creates the Docker image directly without needing a Dockerfile.
Step 4 — Verify Docker Image
Run the following command:
docker imagesYou should see an image similar to this:
REPOSITORY TAG IMAGE ID CREATED
demo-app jib xxxxxxxx 1 minute agoStep 5 — Run the Container
Start the container using:
docker run -p 8080:8080 demo-app:jibNow open:
http://localhost:8080Your application should be running successfully.
Why Use Jib?
Jib provides several advantages compared to traditional Dockerfiles.
1. No Dockerfile Required
Developers can build images directly from Maven or Gradle.
2. Faster Incremental Builds
Jib separates dependencies and application layers efficiently.
This improves caching and reduces rebuild times.
3. Better CI/CD Integration
Jib works well in automated pipelines.
4. Optimized Java Images
Jib generates smaller and cleaner images for Java applications.
Common Commands
Build to Local Docker
mvn compile jib:dockerBuildBuild Directly to Container Registry
mvn compile jib:buildConclusion
Jib is an excellent tool for simplifying Java containerisation.
It removes Dockerfile maintenance, improves build performance, and integrates cleanly into modern DevOps workflows.
For Java developers working with Spring Boot or enterprise applications, Jib can significantly simplify container image creation.
If you are still manually writing Dockerfiles for Java applications, Jib is definitely worth exploring.









