Skip to main content

Jib for Spring Boot: Container Images Without a Dockerfile (vs Buildpacks)

Build one Spring Boot 4.2 app into a container image with Jib 3.5.2 and with Cloud Native Buildpacks, then break both. Real transcripts: five thin layers, a 1.4 KB rebuild delta, identical digests, daemonless registry push, the wrong-JRE trap, and the Buildpacks image that refuses to start at 512 MB.

Most Spring Boot teams end up with a Dockerfile that somebody copied from somewhere, tweaked until it worked, and nobody wants to touch. You pick a base image, copy a jar, guess at JVM memory flags, and hope that a one-line code change does not re-upload 100 MB to the registry. Two tools exist to take that file away: Jib, a Maven (and Gradle) plugin that builds the image layers directly from your compiled project, and Cloud Native Buildpacks, which Spring Boot exposes as spring-boot:build-image. This post builds one small Spring Boot 4.2 application both ways, runs both images, and then breaks them on purpose. You will see exactly what is inside a Jib image, why a one-line change touches a single 1.4 KB layer, why two builds of the same source produce the same digest, how to push without a Docker daemon, and the four ways a Jib build goes wrong. The Buildpacks half is there so you can decide with evidence, not taste — including a failure that appears the moment you put the image under a 512 MB memory limit.
Versions and what was actually run. Spring Boot 4.2.0 (GA 19 November 2026), jib-maven-plugin 3.5.2 (the newest GA on Maven Central; its pom is dated 14 July 2026), Temurin 25.0.5.1+2 (the current LTS) for the build and eclipse-temurin:25-jre as the Jib base image, Buildpacks builder paketobuildpacks/ubuntu-resolute-builder (the Spring Boot 4.2 default) with BellSoft Liberica JRE 25.0.5, Docker Engine 29.9.3.

Two honest caveats. Docker Hub answered 429 Too Many Requests to anonymous pulls while I was writing, so most Jib builds here read the base image from the local Docker daemon (docker://) instead of the registry; the registry-to-registry build later in the post uses the ECR Public mirror of the same image. And timings come from a shared two-core sandbox: they moved by more than 2x between my own runs, so read them as indicative. Every transcript below was produced by scripts/run-all.sh in the companion module and committed under output/.

A container image is a stack of layers, and Jib writes that stack for you

An image is not a mysterious blob. It is a list of compressed file-system archives (layers) plus a small JSON file that says which command to run. A Dockerfile is a recipe: the Docker daemon runs each instruction and snapshots the result into a layer. Jib skips the recipe. It looks at what Maven already produced — your compiled classes, your resources, your dependency jars — packs each group into its own layer, stacks those on top of a base image that already contains a JRE, and writes the result. That has one big practical consequence, visible in the diagram: Jib has three output targets, and only one of them (dockerBuild) needs a Docker daemon. Building straight into a registry or into a tarball never calls Docker.
Dockerfile path Dockerfile Docker daemonruns each instruction layers + config image Jib path target/classes+ dependency jars Jib (Maven plugin)writes the layers itself layers + configbase image reused registry (build) tarball (buildTar) daemon (dockerBuild) Only the dashed target needs a Docker daemon. The other two outputs are produced without calling Docker at all.
The picture is the whole argument for Jib in one frame: the daemon box simply is not on the lower path. That is what makes it pleasant in CI, where a Docker-in-Docker setup is usually the most fragile part of the pipeline.
GoalWhat it doesNeeds the Docker daemon?
jib:buildBuilds and pushes to a registryNo
jib:dockerBuildBuilds into your local Docker daemonYes (uses the docker CLI)
jib:buildTarWrites target/jib-image.tarNo

Source: the jib-maven-plugin README.

Going deeper

  • Jib FAQ on how layers are organised and why a changed file only rebuilds its own layer: Jib FAQ
  • Companion module overview and file index: jib/README.md

The smallest thing that works: one plugin, one command

The application is deliberately tiny: one endpoint that reports which JVM it runs on and how much heap it was given, so every image can be asked the same question. The controller is in src/main/java/com/ankurm/jibdemo/HelloController.java.
@RestController
public class HelloController {

    /** Change GREETING and rebuild to watch exactly one Jib layer change (scripts/04-layer-cache.sh). */
    static final String GREETING = "hello from a Jib image";

    @GetMapping("/hello")
    public Map<String, Object> hello() {
        return Map.of(
                "greeting", GREETING,
                "javaVersion", Runtime.version().toString(),
                "maxHeapMb", Runtime.getRuntime().maxMemory() / (1024 * 1024),
                "user", System.getProperty("user.name"));
    }
}
Jib itself is a plugin block in the pom.xml. The only mandatory setting is the target image name; the rest below is the configuration this post uses.
      <plugin>
        <groupId>com.google.cloud.tools</groupId>
        <artifactId>jib-maven-plugin</artifactId>
        <version>${jib.version}</version>
        <configuration>
          <to>
            <image>${image.name}</image>
            <tags>
              <tag>${project.version}</tag>
            </tags>
          </to>
          <container>
            <ports>
              <port>8080</port>
            </ports>
            <jvmFlags>
              <jvmFlag>-XX:MaxRAMPercentage=75</jvmFlag>
            </jvmFlags>
            <user>1000</user>
            <labels>
              <org.opencontainers.image.title>jib-demo</org.opencontainers.image.title>
              <org.opencontainers.image.source>https://ankurm.com/git.app/asmhatre/java-devops-demo</org.opencontainers.image.source>
            </labels>
            <!-- creationTime defaults to EPOCH, which is what makes two builds byte-identical. -->
          </container>
          <!-- Files under src/main/jib are copied into the image root (src/main/jib/etc/motd.txt -> /etc/motd.txt). -->
        </configuration>
      </plugin>
Then one command, with compile in front (the reason is in the callout below):
$ mvn compile jib:dockerBuild
[INFO] Containerizing application to Docker daemon as jib-demo, jib-demo:1.0.0...
[INFO] Building dependencies layer...
[INFO] Building resources layer...
[INFO] Building classes layer...
[INFO] Building extra files layer...
[INFO] Building jvm arg files layer...
[INFO] Container entrypoint set to [java, -XX:MaxRAMPercentage=75, -cp, @/app/jib-classpath-file, com.ankurm.jibdemo.JibDemoApplication]
[INFO] Built image to Docker daemon as jib-demo, jib-demo:1.0.0
[INFO] BUILD SUCCESS
[INFO] Total time:  6.894 s
That transcript is output/02-jib-build.txt. Running the image and calling it (output/03-run.txt):
$ curl localhost:18080/hello
{"user":"ubuntu","maxHeapMb":371,"javaVersion":"25.0.5.1+2-LTS","greeting":"hello from a Jib image"}
$ curl localhost:18080/actuator/health
{"groups":["liveness","readiness"],"status":"UP"}
Do not run mvn jib:build on its own. Jib does not compile anything; it packages what is already in target/classes. After a clean there is nothing to package, and the error is helpful if you read it to the end:
=== 1. jib:buildTar without compiling first (target/ was just cleaned) ===
$ mvn clean jib:buildTar
[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:3.5.2:buildTar (default-cli) on project jib-demo: Obtaining project build output files failed; make sure you have compiled your project before trying to build the image. (Did you accidentally run "mvn clean jib:build" instead of "mvn clean compile jib:build"?): <module>/target/classes -> [Help 1]
The fix is mvn compile jib:build (or package). Output: output/08-failures.txt.
What each line of the Jib configuration does (intermediate)

to.image and to.tags name the image; ${image.name} is a Maven property so the same pom can push to localhost:5000/jib-demo later without editing anything. container.ports only records EXPOSE 8080 in the image metadata, it does not publish the port. jvmFlags are put into the entrypoint; here -XX:MaxRAMPercentage=75, for a reason shown further down. user sets the runtime user: 1000 exists in the Temurin base image (it is ubuntu, which is why the endpoint reports that name), and without the line the container runs as root. labels become OCI labels.

Anything under src/main/jib is copied into the image root: src/main/jib/etc/motd.txt becomes /etc/motd.txt, and the transcript above reads it back from the running image. That is Jib’s replacement for COPY. It is also the answer to “where do I put a config file?” — but not to “how do I apt-get install something”, which Jib deliberately does not support (see the decision table at the end).

container.creationTime is left at its default, EPOCH, which is the reason created=1970-01-01T00:00:00Z appears in the image config. That looks like a bug and is the single most important setting in the plugin; the reproducibility section explains why.

Going deeper

Inside the image: five thin layers and no fat jar

Spring Boot normally ships a fat jar: your classes and every dependency nested inside one 22 MB archive, launched with java -jar. Put that in a layer and any code change rewrites all 22 MB. Jib does the opposite and un-nests everything. Look inside /app:
=== What is inside /app (no fat jar) ===
classes
jib-classpath-file
jib-main-class-file
libs
resources

HdrHistogram-2.2.2.jar
commons-logging-1.4.0.jar
jackson-annotations-2.21.jar
jackson-core-3.1.8.jar
jackson-databind-3.1.8.jar
... 49 jars in /app/libs

/app/classes:
com

/app/resources:
application.properties
com

jib-demo image: this file came from src/main/jib/etc/motd.txt via extraDirectories

/app/resources
/app/classes
/app/libs/spring-boot-starter-webmvc-4.2.0.jar
There is no jar. There are 49 dependency jars in libs, your classes in classes, and two tiny files that tell the JVM what to run. The entrypoint is therefore not java -jar but java -cp @/app/jib-classpath-file com.ankurm.jibdemo.JibDemoApplication (it is in the Image config block of output/02-jib-build.txt). Each group becomes its own layer:
jib-demo:1.0.0, bottom to top (sizes from output/04) eclipse-temurin:25-jre (6 layers)reused from the registry, never rebuilt dependencies: 49 jars19,883,908 B resources466 B classes (your code)1,445 B jvm arg files (classpath, main class)760 B extra files (/etc/motd.txt)294 B one edited stringa44f4b821f44becomes 1059a437a912other four: unchanged A registry or a CI cache only has to move the amber layer: about 1.4 KB instead of a 20 MB jar.
Read the diagram bottom to top: the Temurin base is reused as-is, then the 20 MB of dependencies, then three or four layers that are each smaller than a kilobyte or two. The amber layer is the one that changes on every commit. The next transcript proves it by editing one string in the controller and listing the five Jib layers before and after (output/04-layer-cache.txt, produced by scripts/04-layer-cache.sh):
=== Build 1: unchanged source ===
a73f075296f4  19883908 bytes  49 files app/libs/HdrHistogram-2.2.2.jar
c40a9f3e76dd       466 bytes   1 files app/resources/application.properties
a44f4b821f44      1445 bytes   2 files app/classes/com/ankurm/jibdemo/HelloController.class
9a14dd547ae2       760 bytes   2 files app/jib-classpath-file
06bc0bf9c586       294 bytes   1 files etc/motd.txt

=== Edit one string in HelloController.java, then build 2 ===
a73f075296f4  19883908 bytes  49 files app/libs/HdrHistogram-2.2.2.jar
c40a9f3e76dd       466 bytes   1 files app/resources/application.properties
1059a437a912      1437 bytes   2 files app/classes/com/ankurm/jibdemo/HelloController.class
9a14dd547ae2       760 bytes   2 files app/jib-classpath-file
06bc0bf9c586       294 bytes   1 files etc/motd.txt

=== Layers whose digest changed (< build 1, > build 2) ===
< a44f4b821f44
> 1059a437a912

=== Files in the layer that changed ===
app/classes/com/ankurm/jibdemo/HelloController.class
app/classes/com/ankurm/jibdemo/JibDemoApplication.class
The 20 MB layer has the same digest in both builds, so a registry that already holds it, or a CI cache keyed on layer digests, transfers about 1.4 KB for the change. A single-layer fat-jar image cannot do that.
How Jib decides what goes in which layer (intermediate)

Per the Jib FAQ the layers are, in order: all other dependencies, snapshot dependencies (so a frequently rebuilt -SNAPSHOT jar does not invalidate the big release-jar layer), project dependencies, resources, classes, and one layer per extraDirectories entry. This project has no snapshot or project dependencies, which is why the build log only says dependencies, resources, classes, extra files, jvm arg files. I verified the layer contents from the tarball, not from the FAQ; the snapshot-layer behaviour I am quoting from the FAQ only.

containerizingMode=packaged and Spring Boot’s repackaged jar (reference)

The default mode is exploded, as above. packaged puts the built jar into the image instead. With Spring Boot that raises an obvious worry: after mvn package the main jar is the 22 MB fat jar. Jib picked the thin one. In output/08-failures.txt, scenario 4, the files in target are 22,327,669 bytes (jib-demo-1.0.0.jar, repackaged) and 4,562 bytes (jib-demo-1.0.0.jar.original), and the image contains only the 4,562-byte one as /app/classpath/jib-demo-1.0.0.original.jar; the container still starts:

=== 4. containerizingMode=packaged after mvn package (Spring Boot repackaged the jar) ===
22327669 target/jib-demo-1.0.0.jar
4562 target/jib-demo-1.0.0.jar.original
$ docker run --rm --entrypoint ls -l /app/classpath
4562 jib-demo-1.0.0.original.jar
INFO 1 --- [jib-demo] [           main] com.ankurm.jibdemo.JibDemoApplication    : Started JibDemoApplication in 2.697 seconds (process running for 3.013)

The Jib FAQ nevertheless discourages containerizing fat jars in general. I did not test the Boot-layered-jar interaction and make no claim about it.

Going deeper

Same sources, same image: why the image says it was created in 1970

A 1970 creation date is deliberate. If the image says it was created decades ago, nothing is wrong. Jib pins the timestamp so the digest depends on content only; the setting is container.creationTime and its default is EPOCH.
Run docker images on a Jib build and the creation date is 1 January 1970. That is not a bug; it is Jib’s default (creationTime=EPOCH), and it exists so that the image digest depends only on content. If the timestamp were the build time, every build would produce a different config file, therefore a different image ID, therefore a “new” image even when not a single byte changed. Two builds of the same source, a few seconds apart (output/05-reproducible.txt):
=== jib:buildTar twice, compare the image digest and id ===
build 1  digest=sha256:01832f5bfbd58a57428f3eeb51c374bcbd672413bdae004ca572497821897a10  id=sha256:35ae49d238eec2ce1035a26a4ac756a0b907e9078902ad28f2bda385ec9ca8d6
build 1  tar sha256 prefix=271ade52b5964451652d
build 2  digest=sha256:01832f5bfbd58a57428f3eeb51c374bcbd672413bdae004ca572497821897a10  id=sha256:35ae49d238eec2ce1035a26a4ac756a0b907e9078902ad28f2bda385ec9ca8d6
build 2  tar sha256 prefix=271ade52b5964451652d

=== Same build with creationTime=USE_CURRENT_TIMESTAMP ===
build 1  digest=sha256:4345a4fbc0cfb58ebf670afcddeedb2f7d3d3f513d9870e97ed1123390f58813
build 2  digest=sha256:093f5af3e98f69abc751cb7bd500da6fec95ac55f990e6b38766074ff904894d
Identical digest and identical image ID with the default; two different digests the moment the timestamp is allowed to be the build time. In practice this means a pipeline can ask “did the image change?” by comparing digests, and a deployment tool will not roll pods for a rebuild that changed nothing.
What else keeps a build reproducible (intermediate)

Two more defaults work together with the epoch: file timestamps inside layers are set to the epoch plus one second (filesModificationTime=EPOCH_PLUS_SECOND, per the README). The remaining moving part is the base image: eclipse-temurin:25-jre is a tag, and tags move. Jib resolves it to a digest at build time and tells you which one (Using base image with digest: sha256:4ed132f6832e... in the registry-push transcript below), so for strict reproducibility put that digest in your from.image. I did not test a digest-pinned from.image; the README documents the from.image parameter generally.

Buildpacks make the same trade with a fixed date of 1 January 1980 (created=1980-01-01T00:00:01Z in the transcript further down). The Spring Boot documentation says the fixed default is what enables reproducible builds; I did not run two Buildpacks builds and compare digests, so treat that as documented, not verified.

Going deeper

Pushing without a Docker daemon: jib:build

This is where Jib earns its keep in CI. jib:build pulls the base image from one registry, builds the layers in memory and pushes them to another. In the transcript below both ends are registries: the base comes from the ECR Public mirror of the official Temurin image, the target is a throwaway registry:2 container on localhost:5000. Docker’s only job here was hosting that registry. (output/09-registry-push.txt, scripts/09-registry-push.sh)
=== mvn jib:build to localhost:5000 (base image pulled from public.ecr.aws/docker/library/eclipse-temurin:25-jre) ===
$ mvn compile jib:build -Dimage.name=localhost:5000/jib-demo -Djib.allowInsecureRegistries=true
[INFO] Containerizing application to localhost:5000/jib-demo, localhost:5000/jib-demo:1.0.0...
[INFO] Getting manifest for base image public.ecr.aws/docker/library/eclipse-temurin:25-jre...
[INFO] Building dependencies layer...
[INFO] Building classes layer...
[INFO] Building extra files layer...
[INFO] Building jvm arg files layer...
[INFO] Building resources layer...
[INFO] Using base image with digest: sha256:4ed132f6832e...
[INFO] Built and pushed image as localhost:5000/jib-demo, localhost:5000/jib-demo:1.0.0
[INFO] BUILD SUCCESS

=== What the registry now holds ===
$ curl localhost:5000/v2/_catalog
{"repositories":["jib-demo"]}

$ curl localhost:5000/v2/jib-demo/tags/list
{"name":"jib-demo","tags":["latest","1.0.0"]}

$ manifest media type and layer count
application/vnd.docker.distribution.manifest.v2+json layers: 11

=== Pull and run what Jib pushed ===
jib-demo image: this file came from src/main/jib/etc/motd.txt via extraDirectories
Eleven layers in the manifest: six from the Temurin base, five from Jib. The last line pulled the image back and read /etc/motd.txt out of it, so what is in the registry is the image you built, not just a manifest that looks right.
Registry authentication (intermediate)

Jib looks for credentials in this order of preference, per the README: the Docker config files (~/.docker/config.json and the containers auth.json locations), a Docker credential helper (credHelper, e.g. ecr-login or gcr), explicit auth.username/auth.password or -Djib.to.auth.* properties, and finally a <server> entry in Maven’s settings.xml whose id matches the registry. The README calls explicit credentials a last resort; if you must use them, read the password from an environment variable rather than committing it. I only exercised an unauthenticated local registry here.

-Djib.allowInsecureRegistries=true, used above, is for plain-HTTP registries such as this localhost one. Do not leave it on in a real pipeline.

Going deeper

Four ways a Jib build goes wrong

The first one you have already seen: forgetting compile. The other three are quieter.

The JRE in the base image is older than your bytecode

Left alone, Jib chooses a Temurin base that matches your Java level (the README lists eclipse-temurin:{8,11,17,21,25}-jre as the defaults, and the build log in output/10-default-base.txt shows it asking for eclipse-temurin:25-jre for this Java 25 project). The trouble starts when somebody sets from.image explicitly and forgets it. Here the same Java 25 classes sit on a Java 21 JRE, and the image builds successfully (output/08-failures.txt, scenario 2):
=== 2. Base image older than the compiled bytecode (class files are Java 25, JRE is 21) ===
$ docker run jib-demo-wrongjre
Error: LinkageError occurred while loading main class com.ankurm.jibdemo.JibDemoApplication
	java.lang.UnsupportedClassVersionError: com/ankurm/jibdemo/JibDemoApplication has been compiled by a more recent version of the Java Runtime (class file version 69.0), this version of the Java Runtime only recognizes class file versions up to 65.0
Class file version 69 is Java 25, 65 is Java 21. Nothing in the build complains; the failure arrives when the container starts. If a pod crash-loops right after a base-image change, check this before anything else.

The JVM sizes its heap from the container limit, and the default is only a quarter

A modern JVM reads the container’s memory limit, but the default MaxRAMPercentage is 25. At a 512 MB limit that is a 128 MB heap, which a Spring Boot application with a few caches outgrows quickly. This module sets 75 through jvmFlags; the numbers (output/08-failures.txt, scenario 3):
=== 3. Heap size at a 512 MB container limit: JVM default vs -XX:MaxRAMPercentage=75 ===
MaxRAMPercentage=25
 size_t MaxHeapSize = 134217728 {product} {ergonomic}
MaxRAMPercentage=75
 size_t MaxHeapSize = 402653184 {product} {ergonomic}
134,217,728 bytes is 128 MiB; 402,653,184 is 384 MiB. Jib does not choose this for you, which is the main difference you will feel against Buildpacks in a moment. Seventy-five percent leaves 128 MiB for metaspace, code cache, thread stacks and direct buffers; raise the limit rather than the percentage if you see the container being OOM-killed.

Docker Hub says no

Jib pulls the base image from a registry, and the registry’s anonymous rate limit becomes your build’s problem. This is what the default build looked like from my sandbox (output/10-default-base.txt):
=== mvn compile jib:buildTar with no base-image override (java.version=25 in the pom) ===
$ mvn compile jib:buildTar
[INFO] Getting manifest for base image eclipse-temurin:25-jre...
[INFO] BUILD FAILURE
[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:3.5.2:buildTar (default-cli) on project jib-demo: 429 Too Many Requests
[ERROR] GET https://registry-1.docker.io/v2/library/eclipse-temurin/manifests/25-jre
[ERROR] {"errors":[{"code":"TOOMANYREQUESTS","message":"You have reached your unauthenticated pull rate limit. Sign in for a higher limit: https://www.docker.com/increase-rate-limit"}]}
The fix is not Jib-specific. Authenticate to Docker Hub (Jib reads the same Docker config files as the docker CLI), mirror the base image into your own registry and point from.image at it, or, as I did for most of this post, read the base from the local daemon with docker://eclipse-temurin:25-jre. The scripts switch between these with one variable, JIB_BASE, documented in scripts/lib.sh.

Going deeper

The same app with Buildpacks

mvn spring-boot:build-image takes a different route. It starts a builder container (in Spring Boot 4.2 the default is paketobuildpacks/ubuntu-resolute-builder), hands it your jar, and a set of buildpacks inspect the application, decide it is a Java app, work out the Java version from the jar’s manifest, download a JRE and assemble the layers. You never choose a base image or write a flag; the buildpacks do. The cost is that a lot happens inside a container you do not control, and one thing in particular matters here:
Jib base image (registry)JRE already inside Jib adds 5 layersyour bytes only image Buildpacks builder containerPaketo buildpacks run here github.comLiberica JRE 25.0.5 tarball imageJRE layer built at build time The red arrows are network calls made inside the builder container. They need egress, and behind a TLS-intercepting proxy they need the proxy address and its CA certificate too (the corp-proxy profile in the pom).
Jib’s JRE is already inside a base image that comes from a registry. The Buildpacks JRE is downloaded from GitHub while the build runs. On an open network you never notice. Behind a TLS-intercepting proxy my first build failed with an error that does not mention a proxy at all (“unable to get dependency BellSoft Liberica JRE”; that first failure is from my notes, not from output/), and you need the proxy address and the proxy’s CA certificate inside the builder. The corp-proxy profile in the pom.xml does exactly that, and the transcript below is the build with it (output/06-buildpacks.txt, a cold build with cleanCache=true):
=== mvn spring-boot:build-image (cold build: cleanCache=true; key lines of the build log) ===
[INFO] Building image 'docker.io/library/jib-demo:buildpacks'
  ===> BUILDING
  Paketo Buildpack for CA Certificates 3.14.8
  Paketo Buildpack for BellSoft Liberica 11.10.6
  Using Java version 25 extracted from MANIFEST.MF
  BellSoft Liberica JRE 25.0.5: Contributing to layer
  Downloading from https://github.com/bell-sw/Liberica/releases/download/25.0.5.1+5/bellsoft-jre25.0.5.1+5-linux-amd64.tar.gz
  Paketo Buildpack for Syft 2.44.2
  Downloading from https://github.com/anchore/syft/releases/download/v1.57.1/syft_1.57.1_linux_amd64.tar.gz
  Paketo Buildpack for Executable JAR 6.17.9
  Paketo Buildpack for Spring Boot 5.41.1
[INFO] Successfully built image 'docker.io/library/jib-demo:buildpacks'
[INFO] BUILD SUCCESS
[INFO] Total time:  18.197 s
Note the line Using Java version 25 extracted from MANIFEST.MF: the buildpack read the Java level from the jar, so you get a Java 25 JRE without asking, and Jib’s “wrong JRE” trap from the previous section does not exist here. Now the two images side by side, same application, same Docker engine:
JibBuildpacks
Image size (docker image inspect)540,348,618 bytes658,601,199 bytes
Layers11 (6 base + 5 Jib)18
Image created1970-01-01T00:00:00Z1980-01-01T00:00:01Z
Runs as1000 (set in the pom; root otherwise)1002:1001, user cnb
Shell in the imageyes (sh works)no (exec: "sh": executable file not found)
Cold build / warm rebuild after a one-line change (seconds, one run, indicative)9 / 1019 / 13

From output/07-compare.txt. Sizes come from this Docker engine’s containerd image store; they are not comparable with sizes in other posts, which used the classic overlay2 store and other base images.

The size and time rows are the least interesting ones, and I would not choose a tool on them. The row to look at is the memory behaviour, because it is where a Buildpacks image can fail at runtime in a way Jib cannot:
=== Run each image under a memory limit ===
--- jib-demo:1.0.0  memory=512m 
{"maxHeapMb":371,"user":"ubuntu","greeting":"hello from a Jib image","javaVersion":"25.0.5.1+2-LTS"}
container memory in use: 141.6MiB / 512MiB
INFO 1 --- [jib-demo] [           main] com.ankurm.jibdemo.JibDemoApplication    : Started JibDemoApplication in 2.558 seconds (process running for 2.85)
--- jib-demo:buildpacks  memory=512m 
container exited with code 82
unable to calculate memory configuration
fixed memory regions require 591743K which is greater than 512M available for allocation: -XX:MaxDirectMemorySize=10M, -XX:MaxMetaspaceSize=79743K, -XX:ReservedCodeCacheSize=240M, -Xss1M * 250 threads
--- jib-demo:buildpacks  memory=512m -e BPL_JVM_THREAD_COUNT=50
{"greeting":"hello from a Jib image","user":"cnb","maxHeapMb":131,"javaVersion":"25.0.5.1+5-LTS"}
container memory in use: 136.9MiB / 512MiB
Calculated JVM Memory Configuration: -XX:MaxDirectMemorySize=10M -Xmx137344K -XX:MaxMetaspaceSize=79743K -XX:ReservedCodeCacheSize=240M -Xss1M (Total Memory: 512M, Thread Count: 50, Loaded Class Count: 11665, Headroom: 0%)
INFO 1 --- [jib-demo] [           main] com.ankurm.jibdemo.JibDemoApplication    : Started JibDemoApplication in 3.036 seconds (process running for 3.359)
--- jib-demo:buildpacks  memory=1g 
{"javaVersion":"25.0.5.1+5-LTS","maxHeapMb":433,"user":"cnb","greeting":"hello from a Jib image"}
container memory in use: 132.4MiB / 1GiB
Calculated JVM Memory Configuration: -XX:MaxDirectMemorySize=10M -Xmx456832K -XX:MaxMetaspaceSize=79743K -XX:ReservedCodeCacheSize=240M -Xss1M (Total Memory: 1G, Thread Count: 250, Loaded Class Count: 11665, Headroom: 0%)
INFO 1 --- [jib-demo] [           main] com.ankurm.jibdemo.JibDemoApplication    : Started JibDemoApplication in 2.895 seconds (process running for 3.259)
The Buildpacks image refuses to start at 512 MB. The Paketo memory calculator reserves fixed regions for every JVM — direct memory, metaspace, a 240 MB code cache, and 1 MB of stack for an assumed 250 threads — and sums to 591,743 KB before it has allocated a single byte of heap. 512 MB is less than that, so the launcher exits with code 82 and the container stops immediately. Two ways out: give it more memory (at 1 GB the heap is 433 MB) or tell it the truth about threads with BPL_JVM_THREAD_COUNT=50 (heap 131 MB at 512 MB). My earlier Dockerizing post hit the same wall on Spring Boot 4.1.1, so this is not a one-off.
Compare that with Jib at the same 512 MB: it starts, with a 371 MB heap, because the flag you wrote in the pom is the only memory configuration there is. Less magic, fewer surprises — and no help when your flag is wrong for the pod you deploy it to.
What changed in Spring Boot 4.2 for Buildpacks (intermediate)

The default builder moved to paketobuildpacks/ubuntu-resolute-builder (Ubuntu 26.04 based) and, per my Spring Boot 4.2 post, the default run image became a tiny one without a shell, which is exactly what the sh: executable file not found row above shows. The build cache can also be an image in a registry now, which helps CI runners that start empty. To keep the older Ubuntu 24.04 builder, set builder and the run image explicitly.

Going deeper

Which one should you use?

If you care about…JibBuildpacks (build-image)
Building in CI without a Docker daemonYes: jib:build / buildTarNo: the plugin needs access to a Docker daemon
Where the JRE comes fromThe base image you point atDownloaded by the builder at build time
JVM memory configurationYou write the flagsA calculator at launch (and it can refuse to start)
Changing the OS or installing packagesNot supported by design: build a custom base imageNot tested here
Changing a file in the imageextraDirectoriesNot tested here
Small push after a code change1.4 KB layer, measured aboveLayered too; sizes in the earlier post
Zero configurationOne plugin blockNone at all, until a proxy or a memory limit

Sources: the transcripts above; the “no RUN” row is the Jib FAQ, which says running commands during the build is not recommended or supported and suggests a custom base image.

Should you switch at all? If you already have a Dockerfile that builds, caches layers properly and nobody fights with, Jib saves you little. It pays off in three situations: CI where a Docker daemon is a liability, registries or links where a 20 MB re-push per commit hurts, and teams that want the image digest to be a pure function of the source. It costs you RUN: the day you need a system package or a CA certificate inside the image, you are maintaining a base image yourself. Buildpacks pay off where a platform team standardises on them and you would rather not own image details at all; budget for the proxy and memory-limit surprises above before you promise that to anyone. Neither is a reason to rewrite a working pipeline.

Further reading

No Comments yet!

This site uses Akismet to reduce spam. Learn how your comment data is processed.