Unable to access jarfile docker using distroless-debug

5/5/2021

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?

-- Jovana Mihaljcic
deployment
docker
jar
java
kubernetes

2 Answers

5/5/2021

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

-- Andrius Burokas
Source: StackOverflow

5/5/2021

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.

-- Jovana Mihaljcic
Source: StackOverflow