Jovana Mihaljcic
Jovana Mihaljcic

Reputation: 87

Unable to access jarfile docker using distroless-debug

I switched from distroless/java:8 to distroless/java:8-debug container and, when deployed to kubernetes, I started getting following error: Error: Unable to access jarfile /MyApp-0.1.jar

This is my Dockerfile:

FROM gcr.io/distroless/java:8-debug
LABEL CONTAINER_NAME=my-api
ARG JAR_FILE=MyApp/core/build/libs/core-0.1-boot.jar
COPY ${JAR_FILE} MyApp-0.1.jar
ENTRYPOINT ["java","-jar","/MyApp-0.1.jar"]

While I was using regular distroless (everything else was the same) I didn't have this problem. What is interesting is that when I try to run this Dockerfile locally, I don't get this error. Is this some permission issue?

Upvotes: 0

Views: 763

Answers (2)

Jovana Mihaljcic
Jovana Mihaljcic

Reputation: 87

I redeployed and it is working now. The only logical explanation is that I tried to use nonroot one first and when I switched to root one, some of the pods with nonroot were still there causing the problem.

Upvotes: 1

Andrius Burokas
Andrius Burokas

Reputation: 66

From what I gathered from this build script: https://github.com/GoogleContainerTools/distroless/blob/main/java/BUILD

Both of those containers are identical. only the debug one includes java compiler

Also, you could try running the app from the container itself. Run something similar to this:

docker run -it --entrypoint sh my-api

running the whoami inside the container verifies that the user is root, so no restrictions should exist

Upvotes: 0

Related Questions