Scrivio Interview library
DebuggingFoundations6 min read · updated 12 November 2026

A Spring Boot container works on a developer's laptop but fails in the cluster with 'exec format error'. Another image fails with permission denied writing to /tmp. Explain both.

An exec format error almost always means the image was built for a different CPU architecture than the node, typically arm64 on an Apple Silicon laptop and amd64 in the cluster; we fix it by building multi-architecture images or building explicitly for the target platform. The permission denied on /tmp comes from the cluster running the container as a non-root user with a read-only root filesystem, while the JVM and Tomcat need to write temporary files; we mount a writable emptyDir at /tmp or point java.io.tmpdir to a writable path, and we test images locally with the same runtime settings.

Why this question is asked

It works on my machine is a familiar sentence, and containers were supposed to end it. These two failures show where they do not: the image depends on the CPU it was built for, and the cluster runs it with security settings the laptop never applied. Interviewers ask this to see whether we understand what an image really contains and how a cluster's security context changes its behaviour. In this answer, we will explain each failure, reproduce it, fix it, and then make local testing match the cluster.

1A Quick Recap: What an Image Depends On

An image looks portable, but it contains compiled binaries: the java executable, the C library, and every native tool in the base image. Those binaries are machine code for one CPU architecture, such as amd64 (x86-64, used by most cloud nodes) or arm64 (Apple Silicon Macs and ARM cloud instances such as AWS Graviton). Java bytecode in our jar is portable; the JVM that runs it is not.

An image also does not decide how it is run. The cluster's pod specification sets the user ID, whether the root filesystem is writable, which capabilities the process has, and more. A laptop running docker run with no options uses permissive defaults; a production cluster usually does not.

2Why exec format error Happens

When the container starts, the kernel tries to execute the entrypoint, for example /opt/java/openjdk/bin/java. If that file is machine code for a different architecture, the kernel cannot run it and returns ENOEXEC, which appears as exec format error. On the laptop, Docker Desktop on an M-series Mac builds arm64 images by default, and the laptop runs them natively. Pushed to a cluster of amd64 nodes, they fail immediately.

Shell
$ docker image inspect orders:1.0 --format '{{.Os}}/{{.Architecture}}'
linux/arm64 # built on an Apple Silicon laptop
$ kubectl logs orders-5f7c-abcde
exec /opt/java/openjdk/bin/java: exec format error
$ kubectl get node worker-1 -o jsonpath='{.status.nodeInfo.architecture}'
amd64

The same error can also appear when the entrypoint is a shell script without a #! line at the top, because the kernel cannot tell how to run it. So if the architectures match, check the script's first line.

3Fixing It: Build for the Target Platform

The simplest fix is to build for the platform the cluster uses. Docker Buildx can build for another architecture using emulation, and with a list of platforms it builds a multi-architecture image: one tag that points to an index of images, one per architecture. Each node then pulls the variant that matches its CPU.

YAML
# Only amd64, for an amd64 cluster
docker buildx build --platform linux/amd64 -t registry.example.com/orders:1.0 --push .
# Multi-architecture: works on amd64 and arm64 nodes
docker buildx build --platform linux/amd64,linux/arm64 -t registry.example.com/orders:1.0 --push .
$ docker buildx imagetools inspect registry.example.com/orders:1.0
Manifests:
Platform: linux/amd64
Platform: linux/arm64

Notice that the base image must also exist for both architectures; official JRE images such as eclipse-temurin publish both. The more reliable long-term fix is to build release images in CI, on runners of the target architecture, and never push images built on laptops. Spring Boot's build-image goal can also target another platform in recent versions, so check your version.

4Why /tmp Is Not Writable

The second image fails differently. The pod spec in the cluster includes a security context like the one below, a common hardening baseline. runAsNonRoot and runAsUser make the process run as an unprivileged user, and readOnlyRootFilesystem mounts the image's filesystem read-only, so a compromised process cannot change binaries or drop files.

YAML
securityContext:
runAsNonRoot: true
runAsUser: 10001
readOnlyRootFilesystem: true
# Application log:
# java.io.IOException: Permission denied
# at java.io.File.createTempFile(...)
# Unable to create tempDir. java.io.tmpdir is set to /tmp
Why each failure happens only in the cluster
SettingLaptop docker runCluster pod
CPU architecturearm64 (native)amd64 nodes
Userroot or image defaultrunAsUser 10001
Root filesystemwritableread-only
/tmpwritableread-only unless a volume is mounted
The image is the same; what differs is the platform and the security context.

A Java application writes to the temp directory more often than we think. Embedded Tomcat creates a work directory under java.io.tmpdir at startup, multipart uploads are buffered there, and libraries extract native code or cache files into it. With a read-only root filesystem, /tmp is part of that read-only filesystem, so every write fails. If the image was built to write somewhere owned by root, a non-root user is refused even without the read-only setting.

5Fixing It: Give the JVM a Writable Place

Keep the hardening and give the application a small writable area. An emptyDir volume mounted at /tmp is created empty for each pod and removed with it. Setting medium: Memory makes it a tmpfs in RAM, which is fast but counts against the container's memory, so we set a size limit. Alternatively, we mount the volume elsewhere and point the JVM at it with -Djava.io.tmpdir, and set server.tomcat.basedir if we want Tomcat's work files in a specific place.

YAML
spec:
containers:
- name: orders
volumeMounts:
- name: tmp
mountPath: /tmp
volumes:
- name: tmp
emptyDir:
sizeLimit: 256Mi
# Startup: Tomcat started on port 8080, temp files in /tmp (writable emptyDir)

Then we test the image locally with the same settings, so the next surprise appears on the laptop: docker run --platform linux/amd64 --user 10001 --read-only --tmpfs /tmp orders:1.0. A CI step that runs a smoke test with these flags catches both problems before deployment.

6Follow-up questions

Is running amd64 images on an arm64 laptop with emulation a good idea?

For a quick check, yes; Docker Desktop can emulate amd64. But emulation makes the JVM much slower, so performance tests on it mean little. For daily development, a multi-architecture image that runs natively on both is more pleasant.

Why not just remove readOnlyRootFilesystem?

Because it is a useful protection. It stops an attacker who gets code execution from changing binaries, planting files in the image or tampering with configuration. Giving the application exactly the writable paths it needs keeps the protection with very little effort.

How do I find every place the app writes?

Run it locally with --read-only and no tmpfs, exercise the main flows, and read the errors. Each failure names a path. Common ones are the temp directory, Tomcat's base directory, and any cache or log directory a library uses. Then mount writable volumes only for those.

7Conclusion

In this answer, we saw that exec format error means the image's binaries were built for a different CPU architecture than the node, usually arm64 from a laptop versus amd64 in the cluster, and we fixed it with docker buildx and multi-architecture images built in CI. We saw that permission denied on /tmp comes from a non-root user with a read-only root filesystem, and fixed it with an emptyDir at /tmp or a custom java.io.tmpdir. Finally, we tested the image locally with the same platform, user and read-only settings as the cluster.

What to say in the interviewAbout 80 seconds aloud

Open with

The two failures have different causes. Exec format error means the kernel could not execute the entrypoint binary. Java bytecode is portable, but the JVM and the base image are native code, and the most common reason is that the image was built on an Apple Silicon laptop, so it is arm64, while the cluster nodes are amd64.

Then, if they want more

I confirm it by inspecting the image architecture and the node architecture. The fix is to build for the target, docker buildx build --platform linux/amd64, or better a multi-architecture image for amd64 and arm64, built in CI rather than on laptops. If the architectures match, I check that an entrypoint script has a proper shebang line.

The permission denied on /tmp comes from the cluster's security context: the pod runs as a non-root user with readOnlyRootFilesystem true, so /tmp is read-only. The JVM and embedded Tomcat write there, Tomcat's work directory, multipart uploads, libraries extracting native code.

I keep the hardening and mount an emptyDir at /tmp with a size limit, or point java.io.tmpdir at a writable mount. And to avoid surprises, I run images locally and in a CI smoke test with the same settings: platform amd64, user 10001, read-only, and a tmpfs for /tmp.

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
Kubernetes documentation
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 "A Spring Boot container works on a developer's laptop but fails in the cluster with...": https://scrivio-interview-library.netlify.app/spring-boot/containers-and-kubernetes/e4dc015f1e/