3

Reproducer

After start the project, I can't connect to the container using docker exec -it sb-repro [bash | sh]. The error:

OCI runtime exec failed: exec failed: unable to start container process: exec: "bash": executable file not found in $PATH: unknown

Is any shell available? Or is it needed to explicitly add some buildpack here?

1
  • Can you edit the question to include a minimal reproducible example, not just an external link? I wouldn't normally expect to get a shell inside a running JVM or Spring Boot application; what makes this an important use case for you? Commented Feb 26, 2024 at 14:21

1 Answer 1

5

To build your container image, you used this specific buildpack:

buildpacks.set(listOf("gcr.io/paketo-buildpacks/java-native-image"))

and you also used the GraalVM Native build tool:

id("org.graalvm.buildtools.native")

If you look at the Gradle Spring Boot plugin documentation, you'll notice that using the build tool makes the plugin use paketobuildpacks/builder-jammy-tiny:latest instead of paketobuildpacks/builder-jammy-base:latest :

paketobuildpacks/builder-jammy-base:latest or paketobuildpacks/builder-jammy-tiny:latest when GraalVM Native Image plugin is applied.

And to make the image size smaller, the tiny variant does not embed common Unix tools such as bash nor sh - which makes the built images even more secure (smaller attack surface) - but less debugable too...

I suggest you debug using the paketobuildpacks/builder-jammy-base:latest base image, run your build with

./gradlew --builder paketobuildpacks/builder-jammy-base:latest bootBuildImage

or updating your build.gradle.kts with:

tasks.withType<BootBuildImage> {
    builder.set("paketobuildpacks/builder-jammy-base:latest")
    ...
}
Sign up to request clarification or add additional context in comments.

2 Comments

This is a nice answer, upvoted. With that said, is there no way to exec into the container? We have a bug that can be produced with the tiny image only, swapping to the jammy base image is not reproducible.
"that can be produced with the tiny image only" ; wow, that sounds really weird; do you have logs / a reproducible test case?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.