Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

How do you build a container image with Cloud Native Buildpacks in Spring Boot, without a Dockerfile?

We run mvn spring-boot:build-image or gradle bootBuildImage. The plugin hands the application to a Cloud Native Buildpacks builder, by default one based on Paketo buildpacks, which picks and installs a JRE, adds a memory calculator that sizes the JVM from the container limit, and arranges the jar into image layers much like a layered jar. We configure the image name and buildpack environment variables such as BP_JVM_VERSION in the plugin, and the build needs a Docker-compatible daemon to run.

Why this question is asked

Many teams do not want every service to carry its own Dockerfile, with its own base image choice and its own mistakes. Buildpacks turn the image build into a standard step: the platform decides how a Java application becomes an image, and the application only declares what it needs. Interviewers ask about it because it is built into Spring Boot's plugins and is a real alternative to writing Dockerfiles. In this answer, we will recap what buildpacks are, build an image with one command, see what the Paketo buildpacks put into it, configure it, and look at what the build needs to run.

1A Quick Recap of Cloud Native Buildpacks

Cloud Native Buildpacks is a CNCF specification for turning source code or a built artefact into an OCI container image without a Dockerfile. A buildpack is a small program that inspects the application, for example detects a Java jar, and contributes layers to the image, such as a JRE or a start command. A builder is an image that bundles a set of buildpacks with a build image and a run image, the base operating system layer that ends up under our application.

Paketo is an open-source project that provides buildpacks and builders for common languages, and Spring Boot's plugins use a Paketo builder by default. The important idea is that the same builder is used for every application, so every image ends up with the same structure, the same base image and the same JRE handling.

2Building an Image With One Command

With Maven or Gradle and the Spring Boot plugin, no extra file is needed.

Shell
$ ./mvnw spring-boot:build-image
# [creator] Paketo Buildpack for BellSoft Liberica: contributing JRE 25
# [creator] Paketo Buildpack for Spring Boot: contributing layers from layers.idx
# Successfully built image 'docker.io/library/orders:1.0.0'
$ ./gradlew bootBuildImage # the Gradle equivalent
$ docker run -p 8080:8080 -m 1g orders:1.0.0
# Calculated JVM Memory Configuration: -Xmx... -XX:MaxMetaspaceSize=... -Xss1M (thread count 250)
Step throughWhat build-image does
  1. Package the jarmvn package or bootJar
  2. Start the builder containerPaketo builder via the Docker daemon
  3. Detect: which buildpacks apply?Java, Spring Boot, ...
  4. Build: contribute layersJRE, memory calculator, app layers
  5. Export image on the run imageorders:1.0.0 in the local daemon

5 steps in order. Play them, or step through them one at a time.

The plugin first builds the jar as usual, then sends it to the builder, which runs the buildpacks inside a container, and finally writes the result as an image to the local Docker daemon. By default the image is named after the project, docker.io/library/<artifactId>:<version>. The first build downloads the builder and run images, so it takes a minute or two; later builds reuse them and are much faster.

3What the Paketo Buildpacks Put Into the Image

The Java buildpacks make a few decisions for us. A JVM provider buildpack (BellSoft Liberica by default, others can be selected) installs a JRE, not a full JDK, of the Java version we request. A memory calculator runs when the container starts: it reads the container's memory limit and sets -Xmx, metaspace, code cache, direct memory and thread stack sizes so that their total fits inside the limit, assuming about 250 threads unless told otherwise. This is the same problem we would otherwise solve by hand with -XX:MaxRAMPercentage.

The Spring Boot buildpack reads the jar's layers index and contributes the application as separate layers: dependencies, loader, snapshot dependencies and application, much as a layered-jar Dockerfile does. So a code change rebuilds and pushes only the small application layer. The image also runs as a non-root user by default, and the buildpacks record a software bill of materials, a list of every component and version, inside the image.

4Configuring the Image

We configure the build in the plugin. The most common settings are the image name, so it goes to our registry, and environment variables that buildpacks read, which mostly start with BP_ for build-time settings and BPL_ for settings read when the container starts.

XML
<!-- pom.xml -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<name>registry.acme.com/orders/${project.artifactId}:${project.version}</name>
<env>
<BP_JVM_VERSION>25</BP_JVM_VERSION> <!-- Java version of the JRE -->
</env>
</image>
</configuration>
</plugin>
// build.gradle.kts
tasks.bootBuildImage {
imageName.set("registry.acme.com/orders/orders:${project.version}")
environment.set(mapOf("BP_JVM_VERSION" to "25"))
}

We can also choose another builder, for example the company's own builder image with an approved base, set publish to true with registry credentials to push straight from the build, or switch on native image builds. The exact default builder name has changed between Boot versions, moving from Ubuntu Jammy to Noble based builders, so check your version if you need to pin it.

5What the Build Needs to Run

The plugin does not implement the buildpacks itself; it talks to a Docker-compatible daemon through its API to pull the builder and run it as a container. So the build machine needs Docker Engine, Docker Desktop, Podman with its Docker-compatible socket, Colima or a similar daemon. In CI this is the main practical obstacle: a runner without access to a daemon cannot run build-image, and we either give the job a Docker socket or a remote Docker host, or use the pack CLI or a platform like kpack that runs buildpacks in a cluster.

The daemon is needed only at build time. The resulting image is a normal OCI image that runs on any container runtime.

6Follow-up questions

Can we see what is inside a buildpack image?

Yes. pack inspect-image shows the buildpacks and run image used, and docker history or dive shows the layers. The SBOM can be downloaded with pack sbom download. This transparency is one of the arguments for buildpacks in organisations with security review.

How do we pass JVM options at run time?

Through the JAVA_TOOL_OPTIONS environment variable on the container, which the JVM reads at start, or BPL_ variables that the buildpack's launch helpers understand, such as the thread count used by the memory calculator. The memory calculator respects explicit settings such as -Xmx and calculates the rest around them.

Does build-image work for native images?

Yes. With GraalVM native support configured, setting the BP_NATIVE_IMAGE environment variable to true, or using the native profile that Boot's parent POM provides, makes the builder compile a native executable and produce a small image without a JRE. The build takes several minutes and needs more memory.

7Conclusion

In this answer, we built a container image without a Dockerfile by running mvn spring-boot:build-image or gradle bootBuildImage. The default Paketo builder detects the Java application, installs a JRE of the version we ask for, adds a memory calculator that sizes the JVM from the container limit, and splits the application into layers like a layered jar. We configured the image name and BP_JVM_VERSION in the plugin, and saw that the build needs a Docker-compatible daemon to run the builder.

What to say in the interviewAbout 80 seconds aloud

Open with

Spring Boot's Maven and Gradle plugins support Cloud Native Buildpacks directly, so I run mvn spring-boot:build-image or gradle bootBuildImage and get an OCI image without writing a Dockerfile.

Then, if they want more

The plugin builds the jar, then runs a builder image, by default a Paketo builder, through the local Docker daemon.

The builder's buildpacks detect that this is a Java and Spring Boot application and contribute layers: a JRE of the version I ask for, BellSoft Liberica by default, and a memory calculator that runs at container start and sets heap, metaspace, code cache and thread stacks to fit inside the container's memory limit.

The Spring Boot buildpack uses the jar's layers index, so dependencies and application code end up in separate layers like a layered jar, and only the small application layer changes on most commits. The image also runs as a non-root user and includes an SBOM.

I configure it in the plugin: the image name with our registry and version, and environment variables like BP_JVM_VERSION set to 25, or a different builder such as a company-approved one, and publish to push straight to the registry. The one requirement is a Docker-compatible daemon, Docker, Podman or Colima, at build time, which matters in CI runners.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Spring Boot reference
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "How do you build a container image with Cloud Native Buildpacks in Spring Boot, without...": https://scrivio-interview-library.netlify.app/spring-boot/packaging-and-deployment/ffa19472c4/